Watir- unable to locate element

Hi everyone,

I am attempting to select link inside of a cell. When i give the direct
path, with exact elements, it works. When i try to pass a variable, it
cannot find the element. any suggestions?

–Works Fine–
Then (/^I select the link$/) do
$browser.form(:id => ‘form0’).div(:id =>
‘CatalogSearchResults’).table.tbody.tr(:id => ‘12345’).td(:class =>
‘Actions’).ul.li.a(:class => ‘add icon labeled’).when_present.click

–Does not work–
Then (/^I select the external app ‘(.*?)’$/) do |app_name|
link_value = config[app_name]
found = nil
$browser.form(:id => ‘form0’).div(:id =>
‘CatalogSearchResults’).table.tbody.tr(:id => ‘link_value’).td(:class =>
‘Actions’).ul.li.a(:class => ‘add icon labeled’).when_present.click

I have a YAML file that contains the variables.

-Also, i understand their might be easier ways to do this, however I am
looking to see if i can get it to work in this fashion.

timed out after 30 seconds, waiting for {:class=>“add icon labeled”,
:tag_name=>“a”} to become present (Watir::Wait::TimeoutError)

Thank you for your support.

You need to remove the quotes around ‘link_value’. That makes it a
String containing the text “link_value” instead of the contents of the
variable link_value: “12345”.

Wow, great call.

Thank you

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs