2012-02-21 40 views
2

我在我的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

回答

0

我建議你的測試套件和測試用例使用java。

我在處理html selenium代碼時遇到了編碼消失。

+0

我們在北京的同事陳雲曉在這裏弄明白了這個訣竅。如果你重命名套件和測試用例文件,使它們具有.html擴展名(並確保從套件到測試用例的引用更新以反映測試用例文件的新名稱),那麼一切都將按預期工作。謝謝, Chenyun – 2012-02-25 00:13:59

0

我確定有一個使用Selenium Server(以前稱爲RC)的解決方案,但我不知道它的副作用。而且我正在開展一個讓我無法研究的項目。

PushToTest TestMaker有一個很棒的命令行界面,可以在桌面,網格或雲環境中運行Selenese Table Format腳本。查看http://www.pushtotest.com/web-testing-with-selenium-pushtotest的教程,看看它們如何融合在一起。

-Frank

6

我們在北京的同事,陳雲肖,這裏想出的伎倆。如果你重命名套件和測試用例文件,以便它們具有.html擴展名(並且確保從套件到測試用例的ref被更新以反映測試用例文件的新名稱),那麼一切都將按預期工作。謝謝,陳雲 - 克里斯貝德福德1分鐘前

+1

儘管缺少最佳答案複選框,並且缺少文件擴展名可能導致此懸掛錯誤的荒謬可笑 - 這個答案解決了我的問題。 – 2014-01-10 19:18:14