Can't click a button on a pop-up in Selenium IDE

夙愿已清 提交于 2019-12-10 11:16:39

问题


I am trying to click a button on a pop-up which is opened from another pop up in Selenium IDE. I have no problem running commands in the second pop i.e. I can search for and select awards however when I try to click the Add button nothing happens. If the step is recorded in IDE the following commands are displayed:

<tr>
    <td>click</td>
    <td>//button[@type='button']</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>id=ctl00_PlaceHolderMain_New_pickerComponents_ButtonAddToTableResults</td>
    <td></td>
</tr>

but this doesn't work. I have also tried:

 <tr>
    <td>click</td>
    <td>xpath=//span[text()='Add']</td>
    <td></td>
</tr>

This is the HTML:

<div class="ui-dialog-buttonpane ui-widget-content ui-helper-clearfix">
<div class="ui-dialog-buttonset">
<button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" role="button" aria-disabled="false">
**<span class="ui-button-text">Add</span>**
</button>
<button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" role="button" aria-disabled="false">
<span class="ui-button-text">Cancel</span>
</button>
</div>
</div>

but no joy. I'm not sure why I can use other commands in this pop-up and not be able to click the add button.


回答1:


As I know, there is no any support in Selenium IDE for multiple windows. Try using selenium WebDriver instead if you have possibility




回答2:


Try with this: ClickAndWait css=button:contains("Add")




回答3:


You can use the below command in your script this will work.

driver.findElement(By.xpath("//span[contains(text(),'Add'")).click;



回答4:


I've had issues where I'd click a link, opening a pop up, and Selenium IDE could not find the element within the pop up. The way I was able to solve this issue, was have the "Implicit Wait" plugin installed. Instead of a "click" on a link, I did a right click and selected "open in new tab" which removed the issue of the pop up and everything worked perfect for me.



来源:https://stackoverflow.com/questions/17449881/cant-click-a-button-on-a-pop-up-in-selenium-ide

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!