【发布时间】:2018-05-08 05:50:54
【问题描述】:
~/tests > uname -a Linux ghopper-K52F 4.10.0-40-generic #44-Ubuntu SMP Thu Nov 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 的提及。 我所有的测试都失败了,浏览器根本没有运行。我在服务器的控制台中得到了日志 sn-p:
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:
...
问题:
- 为什么 Selenium 在没有 webdriver 的情况下运行。
- 如何调试服务器?错误及其原因在哪里?
- 如何查看java及其环境?
附:我在另一台 PC 上做同样的事情,对我来说一切正常。我认为问题出在环境中,而不是在服务器的配置中。
【问题讨论】:
-
我认为这是你的问题 - ~/tests > java -jar -Dwebdriver.chrome.driver=chromedriver selenium-server-standalone-3.7.1.jar
-
它工作正常的另一台 PC 是否有上述 .jar 的文件路径?
-
实际上,我认为是这个 - /home/ghopper/work/***/vendor/phpunit/phpunit selenium/PHPUnit/Extensions/Selenium2TestCase/Driver.php:165 运行 PC它来自(失败)可以访问此文件路径?
-
在我的另一台电脑上:~/work/*** > java -jar -Dwebdriver.chrome.driver=chromedriver selenium-server-standalone-3.7.1.jar 12:10:11.222 信息 - Selenium 构建信息:版本:'3.7.1',修订:'8a0099a' 12:10:11.329 信息 - 找不到驱动程序类:com.opera.core.systems.OperaDriver ... 2017-11-24 12:10: 11.626:INFO:osjs.Server:main: Started @850ms 12:10:11.627 INFO - Selenium Server 已启动并运行
-
当然可以访问测试脚本。
标签: selenium testing webdriver phpunit selenium-chromedriver