如果按钮没有ID,如何使用Selenium按下/单击按钮?

问题描述:

我在同一页面上有2个取消"和下一步"按钮,但只有一个ID(请参见以下代码).我想按下一步",但是每次它仅标识取消"按钮时,而不是下一步"按钮.如何解决此问题?

I have 2 buttons Cancel and Next button on the same page but it has only one id (see the below code). I wanted to press Next but every time it is identifying the cancel button only not Next button. How to resolve this issue?

<td align="center">
     <input type="button" id="cancelButton" value="Cancel" title="cancel" class="Submit_Button" style="background-color: rgb(0, 0, 160);">
     <input type="submit" value="Next" title="next" class="Submit_Button">
</td>

在Selenium IDE中,您可以执行以下操作:

In Selenium IDE you can do:


Command   |   clickAndWait
Target    |   //input[@value='Next' and @title='next']

应该工作正常.