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").