I want to click the \"button\" below, but cannot click it.
The html i
Problem
From the comments we see that there are actually 51 td elements that have the text "Add Intrinsic Filter":
browser.tds(:text => 'Add Intrinsic Filter').length
#=> 51
We also see that some of these cells are visible and some are not - ie when calling .visible?
for each cell, some returned true while others returned false:
browser.tds(:text => 'Add Intrinsic Filter').map(&:visible?).uniq
#=> [false, true]
When locating a single element, Watir will pick the first element that matches. In this case, we can infer that the first cell with text "Add Intrinsic Filter" is not visible:
* The Selenium::WebDriver::Error::ElementNotVisibleError exception does it was not visible.
* Based on the ordering of the results of browser.tds(:text => 'Add Intrinsic Filter').map(&:visible?).uniq
, the first element was not visible.
Without seeing the page, we can only assume that the first matching cell is not the one you actually want to click.
Solution
You need to determine which of the 51 cells is actually the one you want to click and then use a more specific locator.
Based on the result from Selenium IDE, you could do:
browser.td(:xpath => '//tr[@id="filtersJob_intrinsic_container"]/td[2]/table[2]/tbody/tr/td[2]').click
Specifying the whole path to the element can be brittle to changes, so you might want to try something a little less specific. Perhaps try locating the row that has a specific id and then the cell with the specific text:
browser.tr(:id => 'filtersJob_intrinsic_container').td(:class => 'text', :text => 'Add Intrinsic Filter').click
Note that the :class
was added as a locator to try to get the inner td rather than the outer one.