2013-02-25 157 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(); 
相關問題