我想动态使用页面对象。像这样的东西:
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
但是,使用 select_index 对象,而不是 input_field:
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
但这给了我“未定义的方法`state_select_element.option(index,1).select'”的错误
如何才能做到这一点?