chr*_*ude 12 selenium automated-tests selenium-ide
我试图使用selenium ide复制一个动作.该操作是单击打开新窗口的链接.你如何让selenium ide专注于新窗口而不是另一个窗口?它一直没有为我工作.
选择窗口
为此,您需要使用该selectWindow | windowName命令.
要从其他窗口返回主窗口,请执行 selectWindow | null
Run Code Online (Sandbox Code Playgroud)Arguments: * windowID - the JavaScript window ID of the window to select Selects a popup window using a window locator; once a popup window已被选中,所有命令都进入该窗口.要再次选择主窗口,请使用null作为目标.
Run Code Online (Sandbox Code Playgroud)Window locators provide different ways of specifying the window object:按标题,内部JavaScript"名称"或JavaScript变量.
Run Code Online (Sandbox Code Playgroud)* title=My Special Window: Finds the window using the text that出现在标题栏中.小心; 两个窗口可以共享相同的标题.如果发生这种情况,这个定位器只会选择一个.*name = myWindow:使用其内部JavaScript"name"属性查找窗口.这是传递给JavaScript方法window.open(url,windowName,windowFeatures,replaceFlag)的第二个参数"windowName"(Selenium拦截).*var = variableName:某些弹出窗口是未命名的(匿名),但与当前应用程序窗口中的JavaScript变量名称相关联,例如"window.foo = window.open(url);".在这些情况下,您可以使用"var = foo"打开窗口.
Run Code Online (Sandbox Code Playgroud)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 theuser指的是浏览器实例化的原始窗口.
Run Code Online (Sandbox Code Playgroud)2.) if the value of the "windowID" parameter is a JavaScript variable在当前应用程序窗口中的名称,然后假定此变量包含来自JavaScript window.open()方法的调用的返回值.
Run Code Online (Sandbox Code Playgroud)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操作,查看Selenium日志消息,这些消息标识通过window.open创建的窗口的名称(因此被Selenium截获).每个窗口打开时,您都会看到以下消息:
Run Code Online (Sandbox Code Playgroud)debug: window.open call intercepted; window ID (which you can与selectWindow()一起使用是"myNewWindow"
Run Code Online (Sandbox Code Playgroud)In some cases, Selenium will be unable to intercept a call towindow.open(例如,如果在"onLoad"事件期间或之前发生调用).(这是错误SEL-339.)在这些情况下,您可以使用Selenium openWindow命令强制Selenium注意打开窗口的名称,使用空(空白)URL,如下所示:openWindow("","myFunnyWindow") .
selectWindow(WINDOWID)
selectPopup
如果是弹出窗口然后selectPopUp | windowId再回到主窗口那么做selectWindow | null
selectPopUp(windowID) 参数:
简化选择弹出窗口的过程(并不提供超出selectWindow()已提供的功能).
| 归档时间: |
|
| 查看次数: |
47171 次 |
| 最近记录: |