你如何专注于使用selenium ide的新窗户?

chr*_*ude 12 selenium automated-tests selenium-ide

我试图使用selenium ide复制一个动作.该操作是单击打开新窗口的链接.你如何让selenium ide专注于新窗口而不是另一个窗口?它一直没有为我工作.

Aut*_*ter 8

选择窗口

为此,您需要使用该selectWindow | windowName命令.

要从其他窗口返回主窗口,请执行 selectWindow | null

Arguments:

    * windowID - the JavaScript window ID of the window to select

Selects a popup window using a window locator; once a popup window
Run Code Online (Sandbox Code Playgroud)

已被选中,所有命令都进入该窗口.要再次选择主窗口,请使用null作为目标.

Window locators provide different ways of specifying the window object:
Run Code Online (Sandbox Code Playgroud)

按标题,内部JavaScript"名称"或JavaScript变量.

    * title=My Special Window: Finds the window using the text that
Run Code Online (Sandbox Code Playgroud)

出现在标题栏中.小心; 两个窗口可以共享相同的标题.如果发生这种情况,这个定位器只会选择一个.*name = myWindow:使用其内部JavaScript"name"属性查找窗口.这是传递给JavaScript方法window.open(url,windowName,windowFeatures,replaceFlag)的第二个参数"windowName"(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
Run Code Online (Sandbox Code Playgroud)

意思是这样的:

1.) if windowID is null, (or the string "null") then it is assumed the
Run Code Online (Sandbox Code Playgroud)

user指的是浏览器实例化的原始窗口.

2.) if the value of the "windowID" parameter is a JavaScript variable
Run Code Online (Sandbox Code Playgroud)

在当前应用程序窗口中的名称,然后假定此变量包含来自JavaScript window.open()方法的调用的返回值.

3.) Otherwise, selenium looks in a hash it maintains that maps string
Run Code Online (Sandbox Code Playgroud)

名称到窗口"名称".

4.) If that fails, we'll try looping over all of the known windows
Run Code Online (Sandbox Code Playgroud)

试图找到合适的"标题".由于"标题"不一定是唯一的,因此可能会出现意外行为.

If you're having trouble figuring out the name of a window that you want
Run Code Online (Sandbox Code Playgroud)

操作,查看Selenium日志消息,这些消息标识通过window.open创建的窗口的名称(因此被Selenium截获).每个窗口打开时,您都会看到以下消息:

debug: window.open call intercepted; window ID (which you can
Run Code Online (Sandbox Code Playgroud)

与selectWindow()一起使用是"myNewWindow"

In some cases, Selenium will be unable to intercept a call to
Run Code Online (Sandbox Code Playgroud)

window.open(例如,如果在"onLoad"事件期间或之前发生调用).(这是错误SEL-339.)在这些情况下,您可以使用Selenium openWindow命令强制Selenium注意打开窗口的名称,使用空(空白)URL,如下所示:openWindow("","myFunnyWindow") .

selectWindow(WINDOWID)

selectPopup

如果是弹出窗口然后selectPopUp | windowId再回到主窗口那么做selectWindow | null

selectPopUp(windowID) 参数:

  • windowID - 弹出窗口的标识符,可以采用许多不同的含义

简化选择弹出窗口的过程(并不提供超出selectWindow()已提供的功能).

  • 如果未指定windowID或指定为"null",则选择第一个非顶部窗口.顶部窗口是selectWindow()选择的窗口,不提供windowID.当多个弹出窗口正在播放时,不应使用此选项.
  • 否则,将按顺序将windowID视为以下内容查找窗口:
    1. 窗口的"名称",如window.open()所指定
    2. 一个JavaScript变量,它是对窗口的引用
    3. 窗口的标题.这与selectWindow执行的顺序查找相同