検索フィルターがあります。ページ上のすべてのフィールドがそこにあり、値が含まれていることを確認できる必要があります (選択ボックスの場合)。
MethodFinder ジェムを使用してこれを成功させましたが、PageObject ジェムだけで方法があるかどうか疑問に思っていました。
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 要素を返す必要があります。これは一度起こっています。2 番目の puts は、何らかの方法で PageObject オブジェクトに戻すことです。私は今、何が起こっているのかまったくわかりません。上記の出力の一部を次に示します。
#<Watir::Select:0x4c6bdfa4 located=true selector={:id=>"facility-name", :tag_name=>"select"}>
a select tag #<PageObject::Elements::SelectList:0x3101538>