PHP 코드를 테스트하기 위해 selenium2로 phpunit을 실행하려고합니다.phpunit selenium2 반복 테스트가 작동하지 않습니다.
php version : 5.6
laravel version : 5.2
phpunit vesrion : PHPUnit 3.7.28 by Sebastian Bergmann.
초기 명령은 셀레늄 서버 시작 :
java -Dwebdriver.chrome.driver=/usr/bin/chromedriver -jar ~/Downloads/selenium-server-standalone-3.4.0.jar
Mytest.php을
class Mytest extends PHPUnit_Extensions_Selenium2TestCase
{
public function setUp() {
$this->setHost('localhost');
$this->setPort(4444);
$this->setBrowserUrl('http://www.example.com');
$this->setBrowser('chrome'); // firefox
//parent::setUp();
}
public function tearDown() {
$this->stop();
//parent::tearDown();
}
public function testcheckhere(){
$this->url("http://www.google.com");
sleep(5);
}
}
난 다음 명령을 사용하여 명령 줄을 통해 위의 코드를 실행하면 :
vendor/bin/phpunit --filter testcheckhere --verbose --repeat 2 --log-junit textexe.xml tests/selenium/MyTest.php
을
다음 오류가 발생합니다 :
PHPUnit 5.7.9 by Sebastian Bergmann and contributors.
Runtime: PHP 5.6.31-2+ubuntu14.04.1+deb.sury.org+1
Configuration: /var/www/html/CRM/phpunit.xml
.E 2/2 (100%)
Time: 9.04 seconds, Memory: 6.25MB
There was 1 error:
1) Mytest::testcheckhere
PHPUnit_Extensions_Selenium2TestCase_WebDriverException: Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'lp-0500', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-43-generic', java.version: '1.8.0_151'
Driver info: driver.version: unknown
/var/www/html/mycode/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase/Driver.php:165
/var/www/html/mycode/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase/Driver.php:175
/var/www/html/mycode/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase/CommandsHolder.php:100
/var/www/html/mycode/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase.php:394
/var/www/html/mycode/tests/selenium/MyTest.php:29
/var/www/html/mycode/tests/selenium/MyTest.php:29
/var/www/html/mycode/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase.php:348
/var/www/html/mycode/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase.php:314
ERRORS!
Tests: 2, Assertions: 0, Errors: 1.
또한 테스트가 실행되는 동안 크롬 브라우저는 첫 번째 테스트 중에 한 번만 열리고 나중에 다시 열려고 시도하지 않습니다.
그 셀레늄 서버가 webdriver를 어디서 찾을 수 있는지 모르는 것 같다. –
chromeriver binary file과 selenium server jar를 같은 디렉토리에두면 _Dwebdriver.chrome.driver_ parameter를 지정할 필요가 없습니다. asterix와 함께'$ this-> setBrowser ('* chrome')'을 시도하고 _setUp_ 메소드'$ this-> setBrowserUrl'에서 테스트베이스 URL을 설정하면 테스트에서'$ this-> url ('/');'phpunit은 ** test **로 시작하는 모든 메소드를 자동으로 호출하므로 --filter 인수는 필요 없습니다. 이것들은 제 제안이지만, 저는이 문제에있어서 새로운 것입니다. 행운을 빕니다. –