你如何注重与硒的IDE新窗口? [英] How do you focus on new windows with selenium ide?

查看:139
本文介绍了你如何注重与硒的IDE新窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Selenium IDE的复制操作。该动作是点击打开一个新窗口中的链接。如何使硒IDE重点新窗口,而不是另一个呢?它一直没有为我工作。


解决方案

选择窗口

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

要回到主窗口与其他窗口然后执行 selectWindow |空


 参数:    * WINDOWID  - 窗口的JavaScript Window ID选择选择使用窗口定位器弹出式窗口;一旦弹出窗口


  
  

已被选择,所有命令去
  该窗口。要选择主窗口
  再次,使用null作为目标。

 窗口定位器提供指定窗口对象的不同方式:


  
  

按标题,内部的JavaScript
  名,或JavaScript变量。

  *标题=我的特别窗口:查找使用文本窗口


  
  

出现在标题栏。小心;
  两个窗口可以共享相同的标题。
  如果出现这种情况,这将定位器
  随便挑之一。
          *名称= mywindow的:查找使用其内部的JavaScript窗口
  name属性。这是第二个
  参数windowName传递给
  JavaScript方法window.open(URL,
  windowName,windowFeatures,
  replaceFlag)(其硒
  拦截)。
          * VAR = VARIABLENAME:一些弹出窗口是无名
  (匿名),但是与相关的
  在JavaScript变量名
  当前的应用程序窗口,例如
  window.foo = window.open(URL);。在
  这种情况下,你可以打开窗口
  使用VAR = foo的。

 如果没有提供窗口定位器preFIX,我们会试着猜测你


  
  

意思是这样的:

  1)如果WINDOWID为空(或字符串null),则假设


  
  

用户是指原
  窗口由浏览器实例化)。

  2)如果WINDOWID参数的值是一个JavaScript变量


  
  

名称在当前的应​​用
  窗口中,则假定这个
  变量包含返回值
  从对JavaScript调用
  window.open()方法。

  3)。否则,硒看起来在哈希它认为字符串的地图


  
  

名称窗口的名字。

  4)。如果失败,我们会尽力遍历所有已知的窗户


  
  

,试图找到合适的
  标题。由于头衔不是
  一定是唯一的,这可能
  意外的行为。

 如果您遇到麻烦找出你想要一个窗口的名称


  
  

操纵,看硒
  记录哪些识别名称的消息
  窗口通过window.open创建
  (因此由截获
  硒)。你会看到这样的消息
  每个窗口下面,因为它是
  打开:

 调试:window.open呼叫拦截;窗口ID(你可以


  
  

与selectWindow使用())是
  myNewWindow

 在某些情况下,硒将无法拦截调用


  
  

window.open(如果期间发生的呼叫
  或者onload事件之前,为
  例)。 (这是错误SEL-339)。在
  这种情况下,您可以强制硒
  通过使用发现在打开的窗口的名称
  硒的openWindow命令,使用
  空(空白)的URL,如下所示:
  的openWindow(,myFunnyWindow)。


selectWindow(WINDOWID)

selectPopup

如果它是那么一个弹出做 selectPopUp | WINDOWID ,然后回到主窗口办 selectWindow |空

selectPopUp(WINDOWID)
    参数:

  * WINDOWID  - 在弹出窗口的标识符,可以采取一些不同的含义简化了选择的弹出窗口的过程(并没有提供超出selectWindow()已经提供的功能)。    *如果WINDOWID要么是没有指定,或指定为空,则选择第一非顶部窗口。顶部窗口是将由selectWindow()无需提供WINDOWID被选择之一。当多于一个弹出窗口是在播放这不应该被使用。
    *否则,该窗口将被抬起头来考虑WINDOWID如下顺序:窗口1)中的名,按规定对window.open(); 2)JavaScript变量这是一个窗口的引用;和3)窗口的标题。这是由selectWindow进行同样的有序查找。

selectWindow(WINDOWID)

I am trying to use selenium ide to duplicate an action. The action is clicking on a link that open a new window. How do you make selenium ide focus on the new window instead of the other one? It has not been working for me.

解决方案

Select Window

For this you will need to use the selectWindow | windowName command.

To go back to the main window from the other window then do 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

has been selected, all commands go to that window. To select the main window again, use null as the target.

Window locators provide different ways of specifying the window object:

by title, by internal JavaScript "name," or by JavaScript variable.

    * title=My Special Window: Finds the window using the text that

appears in the title bar. Be careful; two windows can share the same title. If that happens, this locator will just pick one. * name=myWindow: Finds the window using its internal JavaScript "name" property. This is the second parameter "windowName" passed to the JavaScript method window.open(url, windowName, windowFeatures, replaceFlag) (which Selenium intercepts). * var=variableName: Some pop-up windows are unnamed (anonymous), but are associated with a JavaScript variable name in the current application window, e.g. "window.foo = window.open(url);". In those cases, you can open the window using "var=foo".

If no window locator prefix is provided, we'll try to guess what you

mean like this:

1.) if windowID is null, (or the string "null") then it is assumed the

user is referring to the original window instantiated by the browser).

2.) if the value of the "windowID" parameter is a JavaScript variable

name in the current application window, then it is assumed that this variable contains the return value from a call to the JavaScript window.open() method.

3.) Otherwise, selenium looks in a hash it maintains that maps string

names to window "names".

4.) If that fails, we'll try looping over all of the known windows

to try to find the appropriate "title". Since "title" is not necessarily unique, this may have unexpected behavior.

If you're having trouble figuring out the name of a window that you want

to manipulate, look at the Selenium log messages which identify the names of windows created via window.open (and therefore intercepted by Selenium). You will see messages like the following for each window as it is opened:

debug: window.open call intercepted; window ID (which you can

use with selectWindow()) is "myNewWindow"

In some cases, Selenium will be unable to intercept a call to

window.open (if the call occurs during or before the "onLoad" event, for example). (This is bug SEL-339.) In those cases, you can force Selenium to notice the open window's name by using the Selenium openWindow command, using an empty (blank) url, like this: openWindow("", "myFunnyWindow").

selectWindow(windowID)

selectPopup

If it is a popup then do selectPopUp | windowId and then to go back to the main window do selectWindow | null

selectPopUp(windowID) Arguments:

    * windowID - an identifier for the popup window, which can take on a number of different meanings

Simplifies the process of selecting a popup window (and does not offer functionality beyond what selectWindow() already provides).

    * If windowID is either not specified, or specified as "null", the first non-top window is selected. The top window is the one that would be selected by selectWindow() without providing a windowID . This should not be used when more than one popup window is in play.
    * Otherwise, the window will be looked up considering windowID as the following in order: 1) the "name" of the window, as specified to window.open(); 2) a javascript variable which is a reference to a window; and 3) the title of the window. This is the same ordered lookup performed by selectWindow .

selectWindow(windowID)

这篇关于你如何注重与硒的IDE新窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆