|
下面是我用selenium IDE 录的脚本
HTML:
<?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://purple-dev/" />
<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>/bugfree/Login.php</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>TestUserName</td>
<td>wangxiangyong</td>
</tr>
<tr>
<td>type</td>
<td>TestUserPWD</td>
<td>123456</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>SubmitLoginBTN</td>
<td></td>
</tr>
<tr>
<td>selectFrame</td>
<td>NavFrame</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>OpenBug</td>
<td></td>
</tr>
<tr>
<td>selectFrame</td>
<td>relative=up</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>BugTitle</td>
<td>test1</td>
</tr>
</tbody></table>
</body>
</html>
JAVA的
package com.example.tests;
import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;
public class Untitled extends SeleneseTestCase {
public void setUp() throws Exception {
setUp("http://purple-dev/", "*chrome");
}
public void testUntitled() throws Exception {
selenium.open("/bugfree/Login.php");
selenium.type("TestUserName", "wangxiangyong");
selenium.type("TestUserPWD", "123456");
selenium.click("SubmitLoginBTN");
selenium.waitForPageToLoad("30000");
selenium.selectFrame("NavFrame");
selenium.click("OpenBug");
selenium.selectFrame("relative=up");
selenium.type("BugTitle", "test1");
}
} |
|