我在我的Mac上運行selenium時遇到問題,因此它只運行一個簡單的測試套件(參見章節'TEST CASE'和'TEST SUITE'),使用以下命令行:無法讓selenium命令行運行HTML測試並記錄輸出,然後退出帶反映測試結果的狀態
java -jar lib/selenium-server.jar -timeout 10 -log server.log -browserSideLog browser.log -debug -htmlSuite' * firefox'http://google.com`pwd`/suite3`pwd`/selenium.html
我的問題是,當測試失敗時,我沒有得到非零的返回碼,而且我也沒有看到任何報告。
我曾嘗試以下的變體:
使用給定的套件和測試用例文件之一:
指定-timeout選項(與正在寫的報道結束急劇),或
不指定-timeout選項。 沒有超時選項中的硒服務器從不關機......即使幫助文件說:
Run a single HTML Selenese (Selenium Core) suite and then exit immediately, using the specified browser (e.g. "*firefox") on the specified URL (e.g. "http://www.google.com").
要解決的竅門我增加了一個額外的硒命令來測試案例來強制關閉如下:
.... previous commands ...
<tr>
<td>open</td>
<td>http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer</td>
<td></td>
</tr>
</tbody>
</table>
</body>
</html>
這確實消除了掛起。瀏覽器關閉,進程終止..但我沒有測試結果,我的退出代碼是(錯誤地)零...不是 非我所期望的。
測試套件(這需要一個名爲「suite3」保存)
<?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://google.com" />
<title>testcase3</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">testcase3</td></tr>
</thead>
<tbody>
<tr>
<td>open</td>
<td>/</td>
<td></td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td>xbout Google</td>
<td></td>
</tr>
</tbody>
</table>
</body>
</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://google.com" />
<title>testcase3</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">testcase3</td></tr>
</thead>
<tbody>
<tr>
<td>open</td>
<td>/</td>
<td></td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td>xbout Google</td>
<td></td>
</tr>
</tbody>
</table>
</body>
</html>
在此先感謝誰可以給我一個線索來解決這個問題! - chris
我們在北京的同事陳雲曉在這裏弄明白了這個訣竅。如果你重命名套件和測試用例文件,使它們具有.html擴展名(並確保從套件到測試用例的引用更新以反映測試用例文件的新名稱),那麼一切都將按預期工作。謝謝, Chenyun – 2012-02-25 00:13:59