简体   繁体   中英

Can't locate button with watir using firefox

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>

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM