I have an error when I try to check if some element is visible. My method is the following:
if find(:xpath, "//td[text()='#{subtab}']").visible?
find(:xpath, "//td[text()='#{subtab}']").click
else
find(:xpath, "//td[text()='#{tab}']").click
find(:xpath, "//td[text()='#{subtab}']").click
end
In if find(:xpath, "//td[text()='#{subtab}']").visible?
, I have:
Capybara::ElementNotFound:
Unable to find xpath "//td[text()='Plan List2']"
but when the element is correctly visible, it works good.
By default capybara won't find non-displayed elements - if you really want find to return both visible and non-displayed elements you can do
a better solution would be to do