我正在使用Selenium IDE。
我用网页上的一个按钮打开了一个W2窗口,命令如下:
window.open(url, "_blank");url有点像http://example.com...
我的窗口是打开的,但会返回到我的主窗口。我不得不关闭W2,所以我试着:
waitForPopUp(title=Sigma+ : Authentification Sigma+)
selectWindow(title=Sigma+ : Authentification Sigma+)
close()我得到了错误[error] Could not find window with title Sigma+ : Authentification Sigma+,但我的窗口W2的标题是:
<head>
<meta content="IE=8" http-equiv="X-UA-Compatible">
<title>Sigma+ : Authentification Sigma+</title>
....我不明白为什么这段代码不能工作。
发布于 2016-02-24 13:21:57
我不知道您使用的是哪种语言,但是通过使用c#,您可以使用以下代码来处理此场景。
尝试以下代码。 C#
var allWindows = driver.WindowHandles;
//for sencode window
driver.SwitchTo().Window(allWindows.Last());
//close sencode window using following
driver.Close(); //it will close second window.
//switch to main window.
driver.SwitchTo().DefaultContent();
//or
driver.SwitchTo().Window(allWindows.First());
//to close firsrt window
driver.Close();//it will close first window;如果有任何问题,请让我知道。
https://stackoverflow.com/questions/35572723
复制相似问题