【发布时间】:2016-01-05 00:42:44
【问题描述】:
我正在通过 selenium-webdriver 测试我的测试用例。我的网络应用程序有一些设置操作,如单击、选择等。我使用了selenium.click() 方法。在测试结束时,我想自动关闭一个弹出窗口。有什么方法可以关闭 Selenium 类中的弹出窗口或浏览器吗?请帮助我是 selenium webdriver 测试的初学者。我用的是selenium server 2.37.0,浏览器是IE。
这是我的代码 sn-p:
namespace SeleniumTests
{
// this is my test method
[TestMethod]
public void TheJan6Test()
{
selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://rcm-bpmt.apmoller.net");
selenium.Start();
verificationErrors = new StringBuilder();
selenium.Open("workspace/faces/jsf/workspace/workspace.xhtml");
// Here the steps regarding the automation of browser
selenium.Type("id=portletComponentWorkList_viewNormalModeWorkList_viewPanel_conditionsTableSearch__OCID0__input", "198545");
selenium.Click("id=portletComponentWorkList_viewNormalModeWorkList_viewPanel_searchWorkList");
selenium.Click("id=portletComponentWorkList:viewNormalModeWorkList:viewPanel:instanceListTableWorkList:_OCID1_:executeLabel");
//I want to close the popup after this step
//At the end of test i want to close the one popup window automatically.Is there is any method to close the popup window or browser in Selenium Class
}
}
请帮助我如何在测试结束时关闭弹出窗口。
【问题讨论】:
-
谷歌上有大量资源供您查找。您是否尝试过搜索?
-
这需要更多上下文。弹出窗口可以是很多东西,例如基本的 JS 弹出窗口、jQuery 模式对话框、一些疯狂的 HTML5 弹出窗口或物理浏览器窗口。那是什么?为我们提供有关该应用程序的更多上下文。此外,您使用的是旧的、已弃用的 (Selenium RC) 版本的 Selenium。