〜/ tests> uname -a Linux ghopper-K52F 4.10.0-40-generic#44-Ubuntu SMP Thu 11月9日14:49:09 UTC 2017 x86_64 x86_64 x86_64 GNU / Linux
~/tests > ls -al
total 37404
drwxrwxr-x 2 ghopper ghopper 4096 ноя 23 22:05 .
drwxr-xr-x 33 ghopper ghopper 4096 ноя 24 10:53 ..
-rwxr-xr-x 1 ghopper ghopper 8799120 ноя 23 10:51 chromedriver
-rwxrwxr-x 1 ghopper ghopper 7194178 окт 31 22:15 geckodriver
-rw-rw-r-- 1 ghopper ghopper 22234765 ноя 23 10:52 selenium-server-standalone-3.7.1.jar
~/tests > apt list --installed | grep openjdk
openjdk-9-jre-headless/zesty,now 9~b161-1 amd64 [installed]
我想用chromedriver启动服务器
~/tests > java -jar -Dwebdriver.chrome.driver=chromedriver selenium-server-standalone-3.7.1.jar
2017-11-24 11:12:16.560:INFO::main: Logging initialized @3822ms to org.seleniumhq.jetty9.util.log.StdErrLog
2017-11-24 11:12:18.501:INFO:osjs.Server:main: jetty-9.4.5.v20170502
2017-11-24 11:12:18.577:WARN:osjs.SecurityHandler:main: ServletContext@o.s.j.s.ServletContextHandler@58a9760d{/,null,STARTING} has uncovered http methods for path: /
2017-11-24 11:12:18.587:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@58a9760d{/,null,AVAILABLE}
2017-11-24 11:12:18.662:INFO:osjs.AbstractConnector:main: Started ServerConnector@66a17408{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
2017-11-24 11:12:18.663:INFO:osjs.Server:main: Started @5924ms
正如我们所看到的,没有任何关于webdriver的提及。 我的所有测试都失败了,浏览器根本没有运行。我在服务器的控制台中获得了日志片段:
Starting ChromeDriver 2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8) on port 8315
Only local connections are allowed.
测试问题:
./vendor/bin/phpunit -v -c tests/phpunit.xml tests/src/Selenium/LoginTest.php
PHPUnit 4.8.36 by Sebastian Bergmann and contributors.
Runtime: PHP 7.0.22-0ubuntu0.17.04.1
Configuration: /home/ghopper/work/***/tests/phpunit.xml
ESSSS
Time: 12.19 seconds, Memory: 6.00MB
There was 1 error:
1) Package\Test\Selenium\LoginTest::testUnauthorizedRandomPage
PHPUnit_Extensions_Selenium2TestCase_WebDriverException:
/home/ghopper/work/***/vendor/phpunit/phpunit selenium/PHPUnit/Extensions/Selenium2TestCase/Driver.php:165
/home/ghopper/work/***/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase/Driver.php:71
/home/ghopper/work/***/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase/SessionStrategy/Isolated.php:67
/home/ghopper/work/***/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase/SessionStrategy/Shared.php:79
/home/ghopper/work/***/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase.php:246
/home/ghopper/work/***/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase.php:287
/home/ghopper/work/***/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase.php:264
--
There were 4 skipped tests:
...
问题:
P.S。我在另一台PC上做同样的事情,一切正常。我认为问题出在环境中,而不是服务器的配置中。
答案 0 :(得分:0)
~/tests > sudo apt-get purge openjdk-9-jre-headless
~/tests > sudo apt install openjdk-8-jre-headless
~/tests > java -jar -Dwebdriver.chrome.driver=chromedriver selenium-server-standalone-3.7.1.jar
12:48:44.839 INFO - Selenium build info: version: '3.7.1', revision: '8a0099a'
12:48:44.841 INFO - Launching a standalone Selenium Server
2017-11-24 12:48:44.885:INFO::main: Logging initialized @534ms to org.seleniumhq.jetty9.util.log.StdErrLog
12:48:45.006 INFO - Driver class not found: com.opera.core.systems.OperaDriver
12:48:45.099 INFO - Driver provider class org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities {browserName: internet explorer, ensureCleanSession: true, platform: WINDOWS, version: }
does not match the current platform LINUX
12:48:45.099 INFO - Driver provider class org.openqa.selenium.edge.EdgeDriver registration is skipped:
registration capabilities Capabilities {browserName: MicrosoftEdge, platform: WINDOWS, version: }
does not match the current platform LINUX
12:48:45.100 INFO - Driver provider class org.openqa.selenium.safari.SafariDriver registration is skipped:
registration capabilities Capabilities {browserName: safari, platform: MAC, version: } does not match the current platform LINUX
12:48:45.226 INFO - Using the passthrough mode handler
2017-11-24 12:48:45.280:INFO:osjs.Server:main: jetty-9.4.5.v20170502
2017-11-24 12:48:45.347:WARN:osjs.SecurityHandler:main: ServletContext@o.s.j.s.ServletContextHandler@30a3107a{/,null,STARTING} has uncovered http methods for path: /
2017-11-24 12:48:45.365:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@30a3107a{/,null,AVAILABLE}
2017-11-24 12:48:45.414:INFO:osjs.AbstractConnector:main: Started ServerConnector@56c57463{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
2017-11-24 12:48:45.414:INFO:osjs.Server:main: Started @1063ms
12:48:45.414 INFO - Selenium Server is up and running
现在一切正常!谢谢)