Selenium - 处理弹出窗口

时间:2012-12-13 05:50:11

标签: selenium selenium-ide

  

可能重复:
  How to record popup windows with selenium IDE

我正在使用Selenium 2测试工具的初学者指南书学习Selenium。我在第1章并尝试处理弹出窗口。

我使用IDE录制了此代码。我正在使用此页面 - http://book.theautomatedtester.co.uk/chapter1

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://book.theautomatedtester.co.uk/" />
<title>New Test</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">New Test</td></tr>
</thead><tbody>
<tr>
    <td>open</td>
    <td>/chapter1</td>
    <td></td>
</tr>
<tr>
    <td>verifyText</td>
    <td>id=divontheleft</td>
    <td>Assert that this text is on the page</td>
</tr>
<tr>
    <td>clickAndWait</td>
    <td>xpath=(//div[@id='multiplewindow'])[2]</td>
    <td>2000</td>
</tr>
<tr>
    <td>selectWindow</td>
    <td>name=popupwindow2</td>
    <td></td>
</tr>
<tr>
    <td>verifyText</td>
    <td>id=popuptext</td>
    <td>Text within the pop up window</td>
</tr>
<tr>
    <td>click</td>
    <td>id=closepopup</td>
    <td></td>
</tr>
<tr>
    <td>selectWindow</td>
    <td>null</td>
    <td></td>
</tr>
<tr>
    <td>verifyElementPresent</td>
    <td>verifybutton</td>
    <td></td>
</tr>

</tbody></table>
</body>
</html>

问题是,它在waitForPopUp上超时。它根本不会打开弹出窗口。

请帮忙吗?

0 个答案:

没有答案