我已经在Ubuntu 16.04上安装了selenium 3.01,chromedriver 2.27和chrome 59。跳过了所有使用chromedriver的phpunit测试
一切工作在我的本地机器上(运行gnome桌面),但不在测试机器上(没有任何GUI)。
我开始与下一个命令的硒(我没有这台机器上的GUI):
[email protected]:~# telnet localhost 4444
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
f
HTTP/1.1 400 No URI
Content-Length: 0
Connection: close
Server: Jetty(9.2.15.v20160210)
Connection closed by foreign host.
:
xvfb-run java -Dwebdriver.chrome.driver=/usr/local/bin/chromedriver -jar /usr/local/bin/selenium-server-standalone-3.0.1.jar -debug
我与它开始于4444端口远程登录检查但是当用phpunit运行测试时,它们会失败:
[email protected]:/var/www/dev.xxx.tt-laravel/site# "vendor/phpunit/phpunit/phpunit" tests/General/NotAuth.php --verbose
PHPUnit 5.7.21 by Sebastian Bergmann and contributors.
Runtime: PHP 7.0.18-0ubuntu0.16.04.1
Configuration: /var/www/dev.domain-laravel/site/phpunit.xml
SS 2/2 (100%)
Time: 2 minutes, Memory: 12.00MB
There were 2 skipped tests:
1) NotAuth::test_shops_index_load
The Selenium Server is not active on host localhost at port 4444.
/var/www/dev.domain-laravel/site/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase.php:299
/var/www/dev.domain-laravel/site/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase.php:337
/var/www/dev.domain-laravel/site/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase.php:314
2) NotAuth::test_shops_categories_load
The Selenium Server is not active on host localhost at port 4444.
/var/www/dev.domain-laravel/site/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase.php:299
/var/www/dev.domain-laravel/site/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase.php:337
/var/www/dev.domain-laravel/site/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase.php:314
OK, but incomplete, skipped, or risky tests!
Tests: 2, Assertions: 0, Skipped: 2.
和硒标签的输出:
2017-07-02 17:18:00.738:INFO::main: Logging initialized @497ms
2017-07-02 17:18:00.870:INFO:osjs.Server:main: jetty-9.2.15.v20160210
2017-07-02 17:18:00.917:INFO:osjsh.ContextHandler:main: Started [email protected]8b42f{/,null,AVAILABLE}
2017-07-02 17:18:00.938:INFO:osjs.ServerConnector:main: Started [email protected]{HTTP/1.1}{0.0.0.0:4444}
2017-07-02 17:18:00.939:INFO:osjs.Server:main: Started @698ms
Starting ChromeDriver 2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320) on port 6589
Only local connections are allowed.
Starting ChromeDriver 2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320) on port 16531
Only local connections are allowed.
任何帮助表示赞赏。谢谢!
PS:这是一个测试:
<?php
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Modelizer\Selenium\SeleniumTestCase;
// https://github.com/Modelizer/Laravel-Selenium
// https://github.com/Modelizer/Laravel-Selenium/wiki/APIs
require_once(__DIR__.'/../../vendor/hacks/load_env.php');
class NotAuth extends SeleniumTestCase
{
/**
* SHOPS MODULES START
*/
public function test_shops_index_load()
{
$url = trim(route('shops_index', [], FALSE));
$this->visit($url)
->see('Top Shops')
->see('Help Center3')
->seePageIs($url)
;
}
public function test_shops_categories_load()
{
$url = trim(route('shops_categories', [], FALSE));
$this->visit($url)
->see('Automotive')
->see('Baby')
->seePageIs($url)
;
}
/**
* SHOPS MODULES END
*/
}
你可以告诉我你的连接代码,你确定它会在没有GUI的情况下工作吗?硒如何打开浏览器? – Dennis
@丹尼斯我正在使用https://github.com/Modelizer/Laravel-Selenium,我会编辑我的问题,并把我写的两个测试之一 –
尝试添加$ this-> setPort(4444);在SeleniumTestCase.php'setUp'方法内部强制端口4444。 – Dennis