giorgiosironi / phpunit-selenium

Selenium RC integration for PHPUnit
http://www.phpunit.de/
Other
601 stars 270 forks source link

php and selenium2testcase Unable to create session #424

Closed vins77 closed 6 years ago

vins77 commented 6 years ago

I'm using phpunit under a windows 10 machine to execute some automated test. I followed instructions as per https://phpunit.de/manual/4.6/en/selenium.html#selenium.selenium2testcase.examples.WebTest.php

Installed software

  1. UwAmp: php version 5.6.18 (server not running)
  2. PHPUnit 5.7.27 by Sebastian Bergmann and contributors
  3. selenium-server-standalone-3.11.0.jar, executed even by giving the path of the used driver (java -jar -Dwebdriver.chrome.driver="./chromedriver.exe" "./selenium-server-standalone-3.11.0.jar"

I created the following sample test case class in file testLogin.php :

class TestLogin extends PHPUnit_Extensions_Selenium2TestCase {

    protected function setUp()
    {
    /*
        $parameters = array(
            'host' => 'localhost',
            'port' => 4444,
            'browser' => ./chromedriver.exe',
            'browserName' => "Chrome",
            'desiredCapabilities' => array(),
            'seleniumServerRequestsTimeout' => 60
        );          
        $this->setHost($parameters['host']);
        $this->setPort($parameters['port']);
        $this->setBrowser($parameters['browser']);
        $this->setBrowserUrl('http://www.example.com/');
        */
        $this->setBrowser('firefox');
        $this->setBrowserUrl('http://www.example.com/');            
    }

    public function testTitle()
    {
        $this->open('http://www.example.com/');
        $this->assertTitle('Example WWW Page');
    }
}

I execute the command as follow: phpunit testLogin.php

And I got the following error:

PHPUnit_Extensions_Selenium2TestCase_WebDriverException: Unable to create session from org.openqa.selenium.remote.NewSessionPayload@60d24d07 Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:33:15.31Z' System info: host: 'PC041IT', ip: '192.168.53.32', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_161' Driver info: driver.version: unknown

F:\Projects\UwAmpLast\UwAmp\www\atcreatecampaign\vendor\phpunit\phpunit-selenium\PHPUnit\Extensions\Selenium2TestCase\Driver.php:165 F:\Projects\UwAmpLast\UwAmp\www\atcreatecampaign\vendor\phpunit\phpunit-selenium\PHPUnit\Extensions\Selenium2TestCase\Driver.php:72 F:\Projects\UwAmpLast\UwAmp\www\atcreatecampaign\vendor\phpunit\phpunit-selenium\PHPUnit\Extensions\Selenium2TestCase\SessionStrategy\Isolated.php:67 F:\Projects\UwAmpLast\UwAmp\www\atcreatecampaign\vendor\phpunit\phpunit-selenium\PHPUnit\Extensions\Selenium2TestCase.php:296 F:\Projects\UwAmpLast\UwAmp\www\atcreatecampaign\vendor\phpunit\phpunit-selenium\PHPUnit\Extensions\Selenium2TestCase.php:337 F:\Projects\UwAmpLast\UwAmp\www\atcreatecampaign\vendor\phpunit\phpunit-selenium\PHPUnit\Extensions\Selenium2TestCase.php:314

Would you be so kind on helping me?

bouraba-hamza commented 6 years ago

sorry for the late response so how you can proceed ? i'm facing the same probleme what i propose to you is to install geckodriver and chromium driver and set it in the variable enviroment to remote control firefox and chrome browser
and change the open( ) method with url( ) because is not known in Selenium2TestCase is a method of SeleniumTestCase

vins77 commented 6 years ago

I managed to solve this on win 10 machine as follow: java -jar -Dwebdriver.gecko.driver=F:\chromedriver32\chromedriver.exe C:\bin\selenium-server-standalone-3.11.0.jar but in the init I did as follow: setBrowser('firefox'); even if I 'm using Chrome

bouraba-hamza commented 6 years ago

yes it's a another solution that i see in the github issue thank you šŸ˜‰

2018-06-12 12:36 GMT+00:00 vins77 notifications@github.com:

I managed to solve this on win 10 machine as follow: java -jar -Dwebdriver.gecko.driver=F:\chromedriver32\chromedriver.exe C:\bin\selenium-server-standalone-3.11.0.jar

ā€” You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/giorgiosironi/phpunit-selenium/issues/424#issuecomment-396573676, or mute the thread https://github.com/notifications/unsubscribe-auth/AXW2U9tqOhnt1_TidOTbxhc6lwuoAkM6ks5t77XcgaJpZM4TMHKC .

vins77 commented 6 years ago

The above workaround solved the issue.