Selenium IDE录制测试弹出窗口
来源:互联网 发布:淘宝卖家创业故事 编辑:程序博客网 时间:2024/05/16 05:44
基于Selenium IDE 2.8.0
录制脚本当点击如下的链接时,系统弹出新窗口
<a target="_blank" href="/portal/site/NewsPortal">See Other News</a>
在不做任何改动直接IDE回放会提示如下信息,
[warn] Link has target '_blank', which is not supported in Selenium! Randomizing target to be: selenium_blank*
并且测试会失败, 原因是selenium执行下一步定位及验证时没有切换到新弹出的页面
看一下selectWindow的API,可以用title, javascript name,和javascript 变量去定位:
- selectWindow(windowID)
- Arguments:
- windowID - the JavaScript window ID of the window to select
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 willjust 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 currentapplication 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 assumedthat 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 messageswhich identify the names of windows created via window.open (and therefore intercepted by Selenium). You will see messageslike 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, usingan empty (blank) url, like this: openWindow("", "myFunnyWindow").
所以解决方案是可以手工加一个selectWindow,并将弹出窗口page title作为参数
那么录制完弹出窗口,怎么返回原先窗口呢? 参考API可以知道,将selectWindow参数设为null就可以了。
原文地址:http://blog.csdn.net/jack0511/article/details/40742761
- Selenium IDE录制测试弹出窗口
- Selenium IDE录制测试弹出窗口
- 自动化测试-selenium IDE脚本录制
- Selenium IDE 脚本录制
- selenium IDE的录制
- selenium ide录制脚本
- Selenium IDE录制脚本
- selenium与webdriver测试弹出窗口
- selenium IDE录制的功能
- selenium IDE录制的功能
- 搭建selenium java测试环境 use selenium IDE自动录制脚本
- Selenium IDE实践(使用Selenium录制)
- Selenium IDE实践(使用Selenium录制)
- Selenium IDE实践(使用Selenium录制)
- selenium IDE窗口介绍
- selenium IDE 测试示例
- Selenium 2 (WebDreiver) 代码示例:弹出窗口测试
- Selenium IDE录制的百度搜索并点击结果测试用例回放报错
- powercfg
- 基于TestNG使用PowerMock的Mockito扩展在Maven测试项目中的配置说明
- 集合框架笔记6(备忘)
- 读书笔记:Deep Learning [Ada-Computation&ML series]--chapter13.Linear factor model
- JavaScript中函数参数的值传递和引用传递
- Selenium IDE录制测试弹出窗口
- 在main函数里面执行一个返回false的函数过程中遇到的坑
- centos7 搭建hadoop2.7.3集群的错误调试
- Function(翻译自mozilla developer network)
- 洛谷 P1072 Hankson 的趣味题(暴力版)
- Spring学习笔记 —— AOP(面向切面编程) 之AspectJ
- **[Lintcode] Max Points on a Line
- 10.25
- oracle用户创建、授权和权限设置