开发者

How can I use xpath in Selenium RC by using Java

开发者 https://www.devze.com 2023-02-14 20:16 出处:网络
My application has the following snippet of code: <form id=\"frmDepartmentCreation\" name=\"frmDepartmentCreation\" method=\"post\"

My application has the following snippet of code:

<form id="frmDepartmentCreation" name="frmDepartmentCreation" method="post" 
      action="">
    <table class="formStyle_1" border="0" cellpadding="0" cellspacing="10" 
            width="100%">
        <tr>
            <td>&nbsp;</td>
            <td align="left"><label class="formBtn_1">
                <input  id="Submit" name="Submit" value="Submit" type="submit" 
                        onclick="return val()"/></label>
                <input type="hidden" name="hdnbu开发者_高级运维tton" id="hdnbutton" value=""/>
            </td>
        </tr>
    </table>
</form>

What is the xpath of "Submit" button considering the above code?


You don't need XPath and I wouldn't recommend using xpath in this situation. In this case id can be used as below:

selenium.click("id=Submit"); 

The above code would do what you want.


//form[@id = 'frmDepartmentCreation']//input[@id = 'Submit'] is one way (starting with // is done as I assume that snippets is part of a larger document.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号