在Selenium IDE中关闭新打开的选项卡或窗口 [英] Close a newly opened tab or window in Selenium IDE
问题描述
使用Selenium IDE和Windows7和Firefox,自动单击链接可能会产生新的标签或新的窗口.
Using Selenium IDE with Windows7 and Firefox, an automatic click on a link may produce either a new tab or a new window.
close()关闭原始窗口或选项卡,而不关闭新窗口或选项卡.也许如果我拥有新创建的ID,则可以选择它然后将其关闭,但是我不知道如何自动执行此操作.我在Selenium论坛上问过并在这里阅读了问题,但它们集中在WebDriver而不是IDE上.任何帮助将不胜感激!
close() closes the original window or tab, not the new one. Maybe if I had the ID of the newly created one I could select it and then close it but I don't know how to do this automatically. I've asked on the Selenium forum and read the questions here, but they focus on WebDriver, not the IDE. Any help would be appreciated!
Stig
推荐答案
我遇到了同样的问题并找到了解决方案:
I had same problem and found a solution:
- 单击打开新标签页的链接
- 添加命令
waitForPopUp
- 通过命令
selectPopUp
将焦点设置到新标签页 - 在新标签中对您的内容进行验证或其他命令
- 使用命令
close
关闭标签页 - 使用命令
selectWindow
将焦点设置到旧窗口
- click on link that opens the new tab
- add command
waitForPopUp
- set focus to new tab via command
selectPopUp
- make your verifications or other commands regarding to your content in new tab
- use command
close
to close tab - use command
selectWindow
to set focus to the old window
我的Selenium IDE命令的屏幕截图:
Screenshot of my Selenium IDE commands:
对我有用.
这篇关于在Selenium IDE中关闭新打开的选项卡或窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!