Answer a question

Google Chrome 79.0.3945.130
ChromeDriver 79.0.3945.36
selenium-server-4.0.0-alpha-4.jar
Newest code from the php-webdriver GitHub as of 1/22/2020

I am starting the Selenium server in standalone mode on localhost using Xfvb as such:

$ Xvfb :99 -screen 5 1920x1080x8 &
$ export DISPLAY=:99
$ java -Dwebdriver.chrome.driver="./chromedriver" -jar selenium-server-4.0.0-alpha-4.jar standalone

I then have a test helper class which starts things up in the PHP code:

    1 final public static function createWebDriver() {
    2   $options = new ChromeOptions();
    3   $options->addArguments(array('--window-size=1920,1080'));
    4   $caps= DesiredCapabilities::chrome();
    5   $caps->setCapability(ChromeOptions::CAPABILITY, $options);
    6   $driver = RemoteWebDriver::create('http://localhost:4444/wd/hub', $caps);
    7   $driver->manage()->window()->maximize();
    8   return $driver;
    9}

When I run a test and call the RemoteWebDriver::create() function, it throws an exception:

Facebook\WebDriver\Exception\UnknownCommandException: Unable to find handler for (POST) /wd/hub/session /home/me/UnitTest/vendor/facebook/webdriver/lib/Exception/WebDriverException.php:137 /home/me/UnitTest/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php:380 /home/me/UnitTest/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:136 /var/www/html/project/core/functions/SeleniumTestHelper.php:6

The line that's the issue is:
$driver = RemoteWebDriver::create('http://localhost:4444/wd/hub', $caps);

I confirm with netstat that I am listening on all addresses to port 4444. I cannot find a directory called "hub" on my machine. I'm not sure why this isn't working and it would seem there is not any more info than this exception for me to go off of.

Answers

andrewnichols helped me out on the GitHub! Here is his response. Many thanks to him. I will share the response here for anyone who comes across this question.

Hi @JoeyofBladez,

Selenium 4 changes the URL. It's no longer behind /wd/hub. The error is correct. It does not know what /wd/hub/session means. The new URL is http://localhost:4444 which would make the new session URL http://localhost:4444/session.

You can view the status at http://localhost:4444/status

Logo

Python社区为您提供最前沿的新闻资讯和知识内容

更多推荐