Arguments:
* windowID - the JavaScript window ID of the window to select
Selects a popup window using a window locator; once a popup window
已被选中,所有命令转到
那个窗口。选择主窗口
再次,使用 null 作为目标。
Window locators provide different ways of specifying the window object:
按标题,按内部 JavaScript
“名称”或 JavaScript 变量。
* title=My Special Window: Finds the window using the text that
出现在标题栏中。当心;
两个窗口可以共享相同的标题。
如果发生这种情况,此定位器将
随便挑一个。
* name=myWindow: 使用其内部 JavaScript 查找窗口
“名称”属性。这是第二个
参数“windowName”传递给
JavaScript 方法 window.open(url,
窗口名称,窗口特征,
replaceFlag)(其中 Selenium
拦截)。
* var=variableName:一些弹窗未命名
(匿名),但与
JavaScript 变量名在
当前应用程序窗口,例如
“window.foo = window.open(url);”。在
那些情况,你可以打开窗口
使用“var=foo”。
If no window locator prefix is provided, we'll try to guess what you
意思是这样的:
1.) if windowID is null, (or the string "null") then it is assumed the
用户指的是原来的
由浏览器实例化的窗口)。
2.) if the value of the "windowID" parameter is a JavaScript variable
当前应用程序中的名称
窗口,那么假设这个
变量包含返回值
从对 JavaScript 的调用
window.open() 方法。
3.) Otherwise, selenium looks in a hash it maintains that maps string
窗口“名称”的名称。
4.) If that fails, we'll try looping over all of the known windows
尝试找到合适的
“标题”。由于“标题”不是
一定是独一无二的,这可能有
意外行为。
If you're having trouble figuring out the name of a window that you want
要操作,看看 Selenium
记录识别名称的消息
通过 window.open 创建的窗口
(因此被截获
硒)。你会看到像这样的消息
每个窗口的以下内容
打开:
debug: window.open call intercepted; window ID (which you can
与 selectWindow()) 一起使用是
“我的新窗口”
In some cases, Selenium will be unable to intercept a call to
window.open(如果调用发生在
或在“onLoad”事件之前,对于
例子)。 (这是错误 SEL-339。)在
在这些情况下,您可以强制 Selenium
通过使用注意打开的窗口的名称
Selenium openWindow 命令,使用
一个空的(空白)网址,如下所示:
openWindow("", "myFunnyWindow").