2013-02-25 156 views
0

我已经在Selenium IDE中构建了一个测试用例。 现在,我如何才能最简单地实现从Netbeans运行的测试用例?如何从Netbeans运行Selenium测试

我的Netbeans版本是7.2。 Selenium服务器在我的Netbeans服务中运行。 这是我对Google搜索的简单测试用例。我试图导出为Java/Junit文件。 Netbeans显示缺少类路径。

<?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="https://www.google.co.in/" /> 
<title>google_search</title> 
</head> 
<body> 
<table cellpadding="1" cellspacing="1" border="1"> 
<thead> 
<tr><td rowspan="1" colspan="3">google_search</td></tr> 
</thead><tbody> 
<tr> 
    <td>open</td> 
    <td>/</td> 
    <td></td> 
</tr> 
<tr> 
    <td>click</td> 
    <td>id=gbqfq</td> 
    <td></td> 
</tr> 
<tr> 
    <td>type</td> 
    <td>id=gbqfq</td> 
    <td>selenium</td> 
</tr> 
</tbody></table> 
</body> 
</html> 

回答

1

在IDE中打开一个新的java项目。

下载硒独立服务器here

将JAR文件中的lib和开始创建Selenium测试案例。

如果你想在Chrome上运行它,然后下载chromedriver.exe文件here

对于对IE运行下载IEDriverServer.exe的相应位版本here

示例代码:

WebDriver driver = new FirefoxDriver(); 
driver.get("URL"); 
//Do some actions 
driver.quit(); 
相关问题