[英]Unable to click on a button in Pop-up in Selenium webdriver using java
I am trying to click on a Yes button on a pop-up window in Selenium and not able to do so. 我试图在Selenium的弹出窗口中单击“是”按钮,但无法这样做。 HTML code is : HTML代码是:
<div id="dialoguebuttons">
<div style="left: 60px; color: rgb(0, 102, 153); padding-top: 5px; font-size: 16px; font-weight: bold; float: left; position: relative;" id="dialog_question">Activate Riskfirst Rapid?</div>
<a id="dialogYesButton" class="button btn-orng" tabIndex="101" href="#">
<span class="btn-inner">Yes</span>
</a>
<a id="dialogNoButton" class="button btn-orng" tabIndex="102" href="#">
<span class="btn-inner">No</span>
</a>
</div>
</div>
Java code I am trying to execute: 我尝试执行的Java代码:
driver.findElement(By.xpath(//*[@id="save_quote_button"]/span)).click(); // After this the pop-up window gets displayed
driver.findElement(By.xpath(//*[@id="dialogYesButton"]/span)).click(); // Trying to click on the Yes button on the pop-up
It just skips the step without actually giving any error. 它只是跳过该步骤而没有实际给出任何错误。
As you are trying to click on the Yes button, this xpath may help you: 当您尝试单击“是”按钮时,此xpath可能会帮助您:
driver.findElement(By.xpath(//*[@id="dialoguebuttons"]/a[text()='Yes')).click();
Let me know if this helps you. 让我知道这是否对您有帮助。
If you are using firefox browser then install firebug
Addon and firepath
Addon and inspect that element using firepath and paste here that xpath between double quotes mentioned in below code: 如果您使用的是firefox浏览器,则安装firebug
Addon和firepath
Addon,并使用firepath检查该元素,并在此代码中粘贴以下代码中双引号之间的xpath:
driver.findElement(By.xpath(" ")).click();
If you are not familiar with firebug
refer this link and try it. 如果您不熟悉firebug
请参考此链接并尝试。 It will help you out. 它将帮助您。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.