It doesn't look like it's just Chrome actually.  I got the same results in 
Firefox.  Looks like the stackoverflow answer addresses the issue?  If I 
change from button type of button to input type of button it works like you 
would expect.

>> b = Watir::Browser.new :firefox
=> #<Watir::Browser:0x110337500 url="about:blank" title="">
>> b.goto("file:///Users/admin/Desktop/button.html")
=> "file:///Users/admin/Desktop/button.html"
>> b.html
=> "<html xmlns=\"http://www.w3.org/1999/xhtml\";><head></head><body><button 
value=\"hey\" onclick=\"alert('Hello world!')\" type=\"button\">Click 
Me!</button></body></html>"
>> b.button.value
=> "hey"
>> b.button(:value => "hey").exists?
=> false
>> b.button(:value => "hey").click
Watir::Exception::UnknownObjectException: unable to locate element, using 
{:value=>"hey", :tag_name=>"button"}
from 
/Library/Ruby/Gems/1.8/gems/watir-webdriver-0.6.4/lib/watir-webdriver/elements/element.rb:490:in
 
`assert_exists'
from 
/Library/Ruby/Gems/1.8/gems/watir-webdriver-0.6.4/lib/watir-webdriver/elements/element.rb:118:in
 
`click'
from (irb):11
# Changed from button to input type of button
>> b.refresh
=> []
>> b.html
=> "<html xmlns=\"http://www.w3.org/1999/xhtml\";><head></head><body><input 
type=\"button\" value=\"hey\" onclick=\"alert('Hello world!')\" />Click 
Me!</body></html>"
>> b.button(:value => "hey").exists?
=> true

On Wednesday, May 15, 2013 5:35:12 PM UTC-4, Chuck van der Linden wrote:
>
> See this SO issue for HTML sample, code samples tried in IRB
>
>   
> http://stackoverflow.com/questions/16574999/watir-webdriver-unable-to-identify-button-by-value
>
> the short of it.  I've got HTML like
>
>    <button type="button" class="btn fb-user-type" name="fbRadios" 
> value="is_agent" style="">An Agent</button>
>
>  When I try to identify the button by class, or text, it works, but by 
> value  such as 
>
>     b.button(:value => "is_agent").exists?
>
> fails  (that returns false, most other stuff returns the typical cannot be 
> located message)
>
> what the heck?  shouldn't this be working?   (Chrome on a Mac) 
>

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to