I am trying to install selenium php binding in my Window 10 computer. I download selenium 3.13.0 and https://code.google.com/archive/p/php-webdriver-bindings/downloads version 0.9.1. I also download geckodriver-v0.21.0-win64.zip and run it ad administrator.
Since my gecko is running on port 4444, I start selenium server on port 4445
java -jar selenium-server-standalone-3.13.0.jar -port 4445
The example code I use is
require_once "phpwebdriver/WebDriver.php";
$webdriver = new WebDriver("localhost", "4445");
$webdriver->connect("firefox");
$webdriver->get("http://google.com");
$element = $webdriver->findElementBy(LocatorStrategy::name, "q");
if ($element) {
$element->sendKeys(array("php webdriver" ) );
$element->submit();
}
But I get the following error. I am using php 5.6.30. My Firefox is 61.0.1. My javs version is 1.8.0_171.
Could someone advise me how to fix the problem? Thanks.
Notice: Undefined property: stdClass::$sessionId in C:\AppServ\www\php-webdriver-bindings\phpwebdriver\WebDriver.php on line 60 stdClass Object ( [sessionId] => [value] => stdClass Object ( [error] => invalid session id [message] => No active session with ID [stacktrace] => ) [status] => 6 )
Fatal error: Uncaught exception 'WebDriverException' with message '6' in C:\AppServ\www\php-webdriver-bindings\phpwebdriver\WebDriverBase.php:130 Stack trace: #0 C:\AppServ\www\php-webdriver-bindings\phpwebdriver\WebDriverBase.php(170): WebDriverBase->handleResponse(Object(stdClass)) #1 C:\AppServ\www\php-webdriver-bindings\example2.php(25): WebDriverBase->findElementBy('name', 'q') #2 {main} thrown in C:\AppServ\www\php-webdriver-bindings\phpwebdriver\WebDriverBase.php on line 130
The selenium server output is :
D:\Selenium-server>java -jar selenium-server-standalone-3.13.0.jar -port 4445 19:12:35.888 INFO [GridLauncherV3.launch] - Selenium build info: version: '3.13.0', revision: '2f0d292'
19:12:35.888 INFO [GridLauncherV3$1.launch] - Launching a standalone Selenium Server on port 4445 2018-07-10 19:12:36.128:INFO::main: Logging initialized @911ms to org.seleniumhq.jetty9.util.log.StdErrLog
19:12:36.923 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4445
19:12:51.768 INFO [ActiveSessionFactory.apply] - Capabilities are: { "browserName": "firefox", "javascriptEnabled": true, "nativeEvents": false, "version": "" }
19:12:51.774 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.firefox.GeckoDriverService)
19:13:02.494 INFO [ActiveSessionFactory.apply] - Capabilities are: { "browserName": "firefox", "javascriptEnabled": true, "nativeEvents": false, "version": "" }
19:13:02.494 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.firefox.GeckoDriverService)