简体   繁体   English

BDD Java / Serenity / Cucumber,如何在没有默认URL的情况下连接页面?

[英]BDD Java/Serenity/Cucumber, how to connect a page without default url?

When creating a page how can i use not defaultURL but dynamic one? 创建页面时,如何不使用defaultURL而是动态页面? My url uses numbering depending one the object i select. 我的网址根据我选择的对象使用编号。 In the example below is "2". 在下面的示例中为“ 2”。 My question is how can i link it with a number in the Feature file where the user of the automation test will require the proper number so also page. 我的问题是我如何将其与功能文件中的数字链接,自动化测试的用户将需要正确的数字,因此页面也是如此。

@DefaultUrl(" http://develop.example.testexample.tool.com/#/triggers/ 2 /add") @At("#HOST/#/2/triggers/add") @DefaultUrl(“ http://develop.example.testexample.tool.com/#/triggers/ 2 / add”)@At(“#HOST /#/ 2 / triggers / add”)

For you to test this page you need to be able to create the underlying object which has the id that makes up the dynamic part of your URL. 为了测试该页面,您需要能够创建具有ID的基础对象,该ID构成URL的动态部分。 In this case your trigger. 在这种情况下,您将触发。 You can retrieve the trigger and use its ID to make your URL. 您可以检索触发器并使用其ID来创建URL。

So with Cucumber you might have something like 因此,使用黄瓜,您可能会遇到类似

Given I have a trigger When I view the triggers add page ... And you could implement that with something like Given I have a trigger When I view the triggers add page ...您可以使用类似的方法来实现

Given 'I have a trigger' do
  @trigger = create_trigger
end

When 'I view the triggers add page' do
  visit trigger_add_page_path(trigger: @trigger)
end

Notice how the variable created in the Given is used in the When. 请注意,在While中如何使用在Given中创建的变量。

You'll have to work out your language/platform specifics that allow you to get this working, but hopefully this is enough to get you started. 您必须确定自己的语言/平台细节,才能使它正常工作,但希望这足以使您入门。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM