The visible? method in the ruby Firewatir 1.6.2 gem isn’t great. After some hunting around, I ended up here and found a working monkeypatch. Here’s the code:
class Element
def visible?
assert_exists
jssh_command = "var val = 'true'; var str = ''; var obj = #{element_object}; while (obj != null) { try { str = document.defaultView.getComputedStyle(obj,null).visibility; if (str=='hidden') { val = 'false'; break; } str = #{DOCUMENT_VAR}.defaultView.getComputedStyle(obj,null).display; if (str=='none') { val = 'false'; break; } } catch(err) {} obj = obj.parentNode; } val;"
jssh_socket.send("#{jssh_command}\n", 0)
vals = read_socket()
return (vals == 'false') ? false : true
end
public:visible?
end
Works for me!
The page I got this from says that the above will be in the next version of Firewatir… I hope so, because it doesn’t work without it!