When using send
, the first argument needs to be a single method. send
does not break up the state_select_element.option(index, 1).select
into 3 method calls.
Since only the first method call state_select_element
needs to evaluated from the string, just use send
for that. The rest can be called as normal. Applying this to your method gives:
def input_select_list(page_object)
wait_until{send("#{page_object}?")}
x = rand(0..send("#{page_object}_element").options.length) - 1
send("#{page_object}_element").option(:index, x).select
end
However, the option
and select
methods will give a depreciation warning. To prevent the error, I would probably re-write the method as:
def input_select_list(page_object)
select = send("#{page_object}_element")
select.when_present
select.select(send("#{page_object}_options").sample)
end