2012-06-19 106 views
4

我在Firefox中使用Selenium IDE以selenese記錄測試套件,並且我想使用Chrome在命令行上運行這些測試。 (我正在運行Mac OS X)。使用Chrome在命令行上運行selenese硒測試

我明顯在做錯事,因爲當我嘗試這樣做時,它會在Firefox中運行。

我下載了OS X的chromedriver和selenium-server-standalone jar文件,並將它們都放在/ usr/local/bin中。我認爲下面的命令可以滿足我的要求,但它會在Firefox而不是Chrome中運行測試。 (請注意,我正在測試運行在http://localhost:8001的本地應用程序)。

$ java -Dwebdriver.chrome.driver=/usr/local/bin/chromedriver \ 
-jar /usr/local/bin/selenium-server-standalone-2.24.1.jar \ 
-htmlSuite "*chrome" http://localhost:8001 /Users/lorin/selenium/suite.html /Users/lorin//selenium/results.html 

輸出看起來是這樣的:

Jun 19, 2012 4:32:40 PM org.openqa.grid.selenium.GridLauncher main 
INFO: Launching a standalone server 
16:32:45.880 INFO - Java: Apple Inc. 20.8-b03-424 
16:32:45.881 INFO - OS: Mac OS X 10.7.4 x86_64 
16:32:45.887 INFO - v2.24.1, with Core v2.24.1. Built from revision 17205 
16:32:45.972 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub 
16:32:45.973 INFO - Version Jetty/5.1.x 
16:32:45.973 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver] 
16:32:45.974 INFO - Started HttpContext[/selenium-server,/selenium-server] 
16:32:45.974 INFO - Started HttpContext[/,/] 
16:32:46.018 INFO - Started [email protected] 
16:32:46.018 INFO - Started HttpContext[/wd,/wd] 
16:32:46.024 INFO - Started SocketListener on 0.0.0.0:4444 
16:32:46.025 INFO - Started [email protected] 
jar:file:/usr/local/bin/selenium-server-standalone-2.24.1.jar!/customProfileDirCUSTFFCHROME 
16:32:46.103 INFO - Preparing Firefox profile... 
16:32:47.013 INFO - Launching Firefox... 
16:32:47.734 INFO - Checking Resource aliases 
16:33:00.781 INFO - Checking Resource aliases 
16:33:00.783 INFO - Received posted results 
16:33:01.537 INFO - Killing Firefox... 
16:33:01.608 INFO - Shutting down... 

回答

5

使用*googlechrome代替鉻。這應該解決它。 * chrome用於在另一種模式下運行firefox。

+0

This works。我是否還需要指定chromedriver? –

+0

嗯,我不確定,因爲我還沒有試圖運行HTML套件。如果拋出錯誤說「找不到路由器」,請在命令中添加路徑。 -Dwebdriver.chrome.driver = 「pathtochromedriver」 –

3

在Firefox中運行它,你應該使用命令*鉻

要在Chrome運行它,你應該使用命令* googlechrome

而且在Internet Explorer中,你應該使用運行* iexplore