I'm just starting out with ruby and firewatir, so I'm trying to find out if it's just me, or if something is broken with firewatir.开发者_如何学Go
I'm trying to select an element using xpath.
This works:
browser.link(:id => "about").exists #true
This fails
browser.link(:xpath => "//*[@id='about']").exists #false
However, this works as well:
browser.element_by_xpath("//*[@id='about']").exists #true
This is on firewatir 1.7.1
$ ruby -v #ruby 1.9.2p136 (2010-12-25 revision 30365) [i686-linux]
Looks like there may be a bug with combining :xpath and multiple attributes, because that XPath query doesn't work for me either when I use :xpath =>:
irb(main):021:0> ff.link(:xpath => "//*[@id='about']").exists?
=> false
But it works if I use the single-attribute style (a comma instead of =>) to find the element, and use "exists?" with a question mark on the end.
Not sure why, but both "exists" and "exists?" are defined, and they have different behavior:
irb(main):018:0> ff.link(:xpath, "//*[@id='about']").exists?
=> true
irb(main):019:0> ff.link(:xpath, "//*[@id='about']").exists
=> ""
精彩评论