我使用Serenity(Thucydides)+ Cucumber在Chrome浏览器中测试Web应用程序。 我想验证页面上是否存在某些元素。
Scenario Outline: Should see six tabs on the page
When I am on MainPage page
Then I should see the following <tab> as tab:
Examples:
| tab |
| Tab_1 |
| Tab_2 |
| Tab_3 |
| Tab_4 |
我成功验证了第一个选项卡,但在第一次迭代后页面重新加载时无法验证其他选项卡。 如何留在同一页面?在我的案子中是否可以管理?
答案 0 :(得分:0)
场景大纲为每个示例元素创建单独的场景。您需要一个查找标签的方案。
更好的方法是编写标签,例如foo-tabs然后写
Scenario: See foo tabs on main page
When I am on the main page
Then I should see foo tabs
在您的步骤定义中,执行编程以查找选项卡,例如
Then "should see foo tabs" do
foo_tabs.each do |tab|
expect(page).to have # do something with the tab here
end
end
(上面是ruby&#39; ish代码,但你应该能够适应java)
现在您将拥有一个场景,如果您添加/删除标签,则无法更改您的功能。
答案 1 :(得分:0)
我错误地使用了前夹具。 我通过设置Global Hook BeforeAll解决了这个问题。