我使用Selenium IDE记录了一个测试套件。我正在测试一个简单的登录页面及其测试用例。我将测试套件导出为Java / TestNG / Remote Control。现在我使用eclipse打开我转换后的测试套件。一个更值得怀疑的是,我在Java / TestNG / Remote Control中转换了测试套件,但为什么要导入junit包
login.java
package com.datadriven;
import junit.framework.Test;
import junit.framework.TestSuite;
public class LoginTestsuit {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(TC-1.1.1.class);
suite.addTestSuite(TC-1.1.2.class);
suite.addTestSuite(TC-1.1.3.class);
suite.addTestSuite(TC-1.1.4.class);
suite.addTestSuite(TC-1.1.5.class);
suite.addTestSuite(TC-1.1.6.class);
return suite;
}
public static void main(String[] args) {
junit.textui.TestRunner.run(suite());
}
}
TC.1.1.1到TC1.1.6是我在测试套件中的测试用例。我不知道如何使用在转换后的测试套件中关联所有这些测试用例。我收到以下错误请参考此链接以查看错误截图 http://i.stack.imgur.com/QH7zJ.png
TC-1.1.1
<?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://localhost:8080/Banking/" />
<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>/Banking/</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>name=sub</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td></td>
<td>5000</td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td>Enter username!</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
TC-1.1.2
</thead><tbody>
tr>
<td>refresh</td>
<td></td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=fname</td>
<td>Jackk</td>
</tr>
<tr>
<td>click</td>
<td>name=sub</td>
<td></td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td>Enter password!</td>
<td></td>
</tr>
</tbody></table>
TC-1.1.3
</thead><tbody>
<tr>
<td>type</td>
<td>id=fname</td>
<td>Jackk</td>
</tr>
<tr>
<td>type</td>
<td>id=Lname</td>
<td>1234567</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>name=sub</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>5000</td>
<td></td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td>Incorrect UserName or Password</td>
<td></td>
</tr>
</tbody></table>
..等等
答案 0 :(得分:1)
试试这个:
Check the version of Selenium IDE you are using, It should be 2.9.0,
Make it sure that you have TestNg integrated with eclipse, else follow these [steps][1],
If you still face the same issue then just remove the junit lib files from your script
and replace them with testng lib
and also do the same for the Junit annotations by replacing testng annotations