ページ オブジェクトを動的に使用したい。このようなもの:
text_field(:company_name_field, id: 'company_directory_name')
select_list(:state_select, id: 'company_directory_workflow_state')
def input_text_field (page_object)
sample_text = Faker::Lorem.paragraph
$text_array.push(sample_text)
wait_until{send("#{page_object}_field?")}
send("#{page_object}_field=", sample_text)
end
ただし、input_field の代わりに select_index オブジェクトを使用すると、次のようになります。
def input_select_list(page_object)
wait_until{send("#{page_object}_select?")}
x = rand(0..send("#{page_object}_select_element.options.length"))
send("#{page_object}_select_element.option(#{:index}, #{x})).select")
end
しかし、これは「undefined method `state_select_element.option(index, 1).select'」というエラーを出しています
これはどのように行うことができますか?