我想验证页面上是否存在所有需要的元素。 我可以在场景大纲的示例部分中列出它们。例如:
Scenario Outline: I am able to see all elements on My Page
When I am on my page
Then I should see the following <element> My Menu
Examples:
| element |
| MENU button |
| MY logo |
| MY_1 link |
| MY_2 link |
| Button_1 button |
| Button_2 button |
| Loggin button |
每一行运行一个单独的方法来验证页面上元素的存在。问题是 - 页面已重新加载。 如何以更合适的方式解决问题?
最佳答案
您不需要场景大纲。您只需要一个步骤来验证表中的所有元素。
Scenario: I am able to see all elements on My Page
When I am on my page
Then I should see the following elements in My Menu
| MENU button |
| MY logo |
| MY_1 link |
| MY_2 link |
| Button_1 button |
| Button_2 button |
| Loggin button |
您可以将表用作数组的数组:
Then(/^I should see the following elements in My Menu$/) do |table|
table.raw.each do |menu_item|
@my_page_object.menu(menu_item).should == true
end
end
When(/^I am on my page$/) do
@my_page_object = MyPageObject.new(browser)
end
关于java - 如何验证页面上的所有元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31700606/