我有一个搜索过滤器。我需要能够检查页面上的所有字段都存在并包含值(如果它们是选择框)。迭代页面对象的所有元素
我已经使用了MethodFinder gem来成功地做到这一点,但我想知道是否有任何与PageObject gem的方式。
require 'methodfinder'
class BasicSearchFilter
include PageObject
text_field(:facility_name, :id => "facility-name")
text_field(:queue, :id => "queue")
select_list(:from, :id => "from")
button(:continue, :id => "continue")
def get_search_filter_elements
methods = MethodFinder.find_in_class_or_module('BasicSearchFilter', '.*_element$')
elements = []
methods.each do |method|
elements << send(method)
end
end
end
我已经成功地使用了上述,但现在我无法使用我想要做的页面对象方法。我希望能够以某种方式提交一个有效的“元素”列表,这些元素只是PageObject版本的元素。
编辑:所以事实证明,一些非常可怕的事情正在发生。 我有一个RSpec测试从上面的类中获取字段。它看起来像这样:
it "the basic filter dropdowns should not contain duplicate values"
on_page(BasicSearchFilter).get_search_filter_elements.each do |element|
if element.tag_name == "select"
p element
puts "a select tag #{element}"
end
end
end
现在根据文档your_element_element命令应该返回的Watir元素。发生过一次。第二个投入是以某种方式改回到PageObject对象。我现在完全不知道发生了什么。这是上面的一些输出。
#<Watir::Select:0x4c6bdfa4 located=true selector={:id=>"facility-name", :tag_name=>"select"}>
a select tag #<PageObject::Elements::SelectList:0x3101538>