0

Have tried multiple variations. Even used Testwise 3 recorder to see if it came up with something different. For some reason, I can't get watir to click on this OK button. It just keeps saying assert_exists : unable to locate element. I'm using Firefox 15.

$browser.button(:value,"OK").click

Ideas?

<TABLE  BORDER="0" CELLPADDING="1" CELLSPACING="4" summary="">
<TR>
<TD><INPUT TYPE="BUTTON" VALUE="OK"     onClick="javascript:buttonSubmit('OK')" CLASS="OraButton"></TD>
<TD><INPUT TYPE="BUTTON" VALUE="Cancel" onClick="javascript:buttonSubmit('CANCEL')" CLASS="OraButton"></TD>
</TR>
</TABLE>
Ripon Al Wasim
  • 36,924
  • 42
  • 155
  • 176
Derek
  • 95
  • 1
  • 5
  • It might possibly be because the developer for some reason repeats this exact same block twice on the page. So the same OK and CANCEL buttons are on there twice with the same values. If this is the case, how do I tell it to just click on the first one that matches value=OK? – Derek Sep 20 '12 at 14:50
  • I also tried identifying first button using index, but still getting: C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.1/lib/watir-webdriver/elements/element.rb:365:in `assert_exists': unable to locate element, using {:index=>1, :tag_name=>"button"} (Watir::Exception::UnknownObjectException) from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.1/lib/watir-webdriver/elements/element.rb:95:in `click' – Derek Sep 20 '12 at 15:06

1 Answers1

1

It looks like watir-webdriver (or selenium-webdriver) is case-sensitive when looking for the input's type attribute value.

I was able to get it to work by either fixing the HTML:

<INPUT TYPE="button" VALUE="OK" onClick="javascript:buttonSubmit('OK')" CLASS="OraButton">

Or using an xpath locator:

$browser.button(:xpath, '//INPUT[@TYPE="BUTTON"]').click
Justin Ko
  • 46,526
  • 5
  • 91
  • 101
  • Thanks so much. That would have taken me all day to figure out. Saved me from a huge headache. – Derek Sep 20 '12 at 16:08