selenium自动化测试框架-选择窗口篇
来源:互联网 发布:单片机脉冲计数器 编辑:程序博客网 时间:2024/05/22 20:28
1.selectWindow问题。
selectWindow TestOpenWindow如果程序打开了新窗口,那么就要转到新窗口 执行一些操作,这时需要首先选中该新窗口,在selenium中选中新窗口使用selectWindow命令,根据windowID来选择窗口,但是它有一些限制:
a. 只能检测到使用window.open(url, windowName, windowFeatures, replaceFlag)方法打开的窗口。
b. 如果在onLoad事件之前发生的打开窗口,并不能检测到。使用以下命令注册窗口后就能选择。
openWindow TestOpenWindow源代码如下:
<!--File: TestOpenWindowDuringOnLoad.html-->
<html>
<head>
<title>Test Local</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<tbody>
<tr>
<td rowspan="1" colspan="3">Test Local<br>
</td>
</tr>
<tr>
<td>open</td>
<td>http://10.202.15.118:8080/myapp/test_open_window_during_onload.jsp</td>
<td> </td>
</tr>
<tr>
<td>openWindow</td>
<td></td>
<td>TestOpenWindowDuringOnLoad</td>
</tr>
<tr>
<td>waitForPopUp</td>
<td>TestOpenWindowDuringOnLoad</td>
<td>5000</td>
</tr>
<tr>
<td>selectWindow</td>
<td>TestOpenWindowDuringOnLoad</td>
<td> </td>
</tr>
<tr>
<td>verifyTitle</td>
<td>Test HTML</td>
<td> </td>
</tr>
</tbody>
</table>
</body>
</html>
<head>
<title>Test Local</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<tbody>
<tr>
<td rowspan="1" colspan="3">Test Local<br>
</td>
</tr>
<tr>
<td>open</td>
<td>http://10.202.15.118:8080/myapp/test_open_window_during_onload.jsp</td>
<td> </td>
</tr>
<tr>
<td>openWindow</td>
<td></td>
<td>TestOpenWindowDuringOnLoad</td>
</tr>
<tr>
<td>waitForPopUp</td>
<td>TestOpenWindowDuringOnLoad</td>
<td>5000</td>
</tr>
<tr>
<td>selectWindow</td>
<td>TestOpenWindowDuringOnLoad</td>
<td> </td>
</tr>
<tr>
<td>verifyTitle</td>
<td>Test HTML</td>
<td> </td>
</tr>
</tbody>
</table>
</body>
</html>
<!--File: test_open_window_during_onload.jsp-->
<html>
<head>
<title>Test Open Window</title>
</head>
<body>
<center>
<text id=text1>Hello, Open a new Window During OnLoad!</text>
</center>
</body>
</html>
<script language=javascript>
myLoad();
function myLoad(){
window.open("test.html","TestOpenWindowDuringOnLoad");
}
</script>
<head>
<title>Test Open Window</title>
</head>
<body>
<center>
<text id=text1>Hello, Open a new Window During OnLoad!</text>
</center>
</body>
</html>
<script language=javascript>
myLoad();
function myLoad(){
window.open("test.html","TestOpenWindowDuringOnLoad");
}
</script>
c.如果使用window.open(url),未指定窗口ID,那么使用undefined标志窗口ID来选择窗口。
selectWindow undefined源代码如下:
<!--File: TestOpenWindowWithoutID.html-->
<html>
<head>
<title>Test Local</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<tbody>
<tr>
<td rowspan="1" colspan="3">Test Local<br>
</td>
</tr>
<tr>
<td>open</td>
<td>http://10.202.15.118:8080/myapp/test_open_window_without_id.jsp</td>
<td> </td>
</tr>
<tr>
<td>click</td>
<td>testopenwindow</td>
<td> </td>
</tr>
<tr>
<td>waitForPopUp</td>
<td>undefined</td>
<td>5000</td>
</tr>
<tr>
<td>selectWindow</td>
<td>undefined</td>
<td> </td>
</tr>
<tr>
<td>verifyTitle</td>
<td>Test HTML</td>
<td> </td>
</tr>
</tbody>
</table>
</body>
</html>
<head>
<title>Test Local</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<tbody>
<tr>
<td rowspan="1" colspan="3">Test Local<br>
</td>
</tr>
<tr>
<td>open</td>
<td>http://10.202.15.118:8080/myapp/test_open_window_without_id.jsp</td>
<td> </td>
</tr>
<tr>
<td>click</td>
<td>testopenwindow</td>
<td> </td>
</tr>
<tr>
<td>waitForPopUp</td>
<td>undefined</td>
<td>5000</td>
</tr>
<tr>
<td>selectWindow</td>
<td>undefined</td>
<td> </td>
</tr>
<tr>
<td>verifyTitle</td>
<td>Test HTML</td>
<td> </td>
</tr>
</tbody>
</table>
</body>
</html>
<!--File: test_open_window_without_id.jsp-->
<html>
<head>
<title>Test Open Window</title>
</head>
<body>
<center>
<text id=text1>Hello, Open a new Window Without ID!</text>
<button id="testopenwindow" onclick='javascript:myLoad()'>TestOpenWindowWithoutID</button>
</center>
</body>
</html>
<script language=javascript>
function myLoad(){
window.open("test.html");
}
</script>
<head>
<title>Test Open Window</title>
</head>
<body>
<center>
<text id=text1>Hello, Open a new Window Without ID!</text>
<button id="testopenwindow" onclick='javascript:myLoad()'>TestOpenWindowWithoutID</button>
</center>
</body>
</html>
<script language=javascript>
function myLoad(){
window.open("test.html");
}
</script>
- selenium自动化测试框架-选择窗口篇
- 【转】 selenium自动化测试框架-选择窗口篇
- Selenium自动化测试框架
- 自动化测试框架Selenium 入门
- Selenium 的自动化测试框架
- selenium+java自动化测试框架之元素管理篇
- (翻译)选择测试自动化框架
- 如何选择自动化测试框架?
- 自动化测试框架/工具选择
- 如何选择自动化测试框架
- 针对Selenium RC的自动化测试框架
- 基于selenium的自动化测试框架
- web自动化测试框架(Selenium+TestNG)
- 基于selenium的自动化测试框架实现
- Selenium自动化测试框架第一篇
- 简易selenium自动化测试框架(Python)
- 基于Selenium的自动化测试框架
- 简单学习自动化测试框架(selenium)
- [项目:address1]通讯录综合示例(界面篇)
- 用.NET创建Windows服务
- PHP 設計模式
- ajax 实现三级联动功能
- 初次接触asp.net
- selenium自动化测试框架-选择窗口篇
- 英雄会的郁闷与收获
- 要更深入研究SWT
- 应聘Java笔试时可能出现问题及其答案
- JSF和Spring集成
- MFC文档/视图架构之视图
- 禁止搜索引擎收录的方法
- CSS的常用技巧
- Windows Mobile 2005网络连接之真机和模拟器的异同