如果按钮没有ID,如何使用Selenium按下/单击按钮? [英] How to press/click the button using Selenium if the button does not have the Id?

查看:607
本文介绍了如果按钮没有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']

应该工作正常.

这篇关于如果按钮没有ID,如何使用Selenium按下/单击按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆