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)
Download chrome driver and try below command
To register a Selenium Grid Hub you need to use the following command:
>java -jar /Users/admin/selenium-server-standalone-3.14.0.jar -role hub
To register a Selenium Grid Node for ChromeDriver and Chrome you need to pass the absolute path of the ChromeDriver along with the Key and Value of the Registration URI as follows:
>java -Dwebdriver.chrome.driver=/path/to/chromedriver.exe -jar /Users/admin/selenium-server-standalone-3.14.0.jar -role node -hub http://<IP_GRID_HUB>:4444/grid/register
Related
I'm using this repo to connect to SAP software:
https://github.com/gkralik/php7-sapnwrfc
but I don't know why my script connect and return data successfully from my zfunctions on SAP server only under Command Line Interface CLI
php /path/tomy/script.php
but errors under web browser always return:
Fatal error: Uncaught SAPNWRFC\ConnectionException: Failed to set trace directory in /var/www/html/sap/test.php
or
Exception: Could not open connection
Exception INFO:
Array
(
[code] => 1
[key] => RFC_COMMUNICATION_FAILURE
[message] =>
LOCATION CPIC (TCP/IP) on local host with Unicode
ERROR partner 123.4.5.6:3300 not reached
TIME Sat Feb 4 23:42:27 2023
RELEASE 753
COMPONENT NI (network interface)
VERSION 40
RC -10
MODULE /bas/753_REL/src/base/ni/nixxi.cpp
LINE 3067
DETAIL NiPConnect: 123.4.5.6:3300
SYSTEM CALL connect
ERRNO 13
ERRNO TEXT Permission denied
COUNTER 6
)
with any user, and I have checked file permissions too.
Thank you very much for your help
By default, SELinux forbids Apache to make outgoing network connections. If Apache needs to make requests to an outside network service, then run the following command to allow this action.
setsebool -P httpd_can_network_connect on
I have a problem with web driver startup for selenium on Ubuntu 14.04.
I've already installed Oracle JDK and Selenium Standalone Server, also have no issue with running Selenium Standalone Server on Ubuntu 14.04 (I use cloud9 VDS).
But when I try to run this example an error occurs (Unable to create new service):
Fatal error: Uncaught exception 'Facebook\WebDriver\Exception\SessionNotCreatedException' with message ' in /home/ubuntu/workspace/php-web-driver-test/vendor/facebook/webdriver/lib/Exception/WebDriverException.php on line 154 Facebook\WebDriver\Exception\SessionNotCreatedException: Unable to create new service: ChromeDriverService Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:08.936Z' System info: host: 'user-selenium-6138185', ip: '173.18.0.42', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.80-c9', java.version: '1.8.0_171' Driver info: driver.version: unknown in /home/ubuntu/workspace/php-web-driver-test/vendor/facebook/webdriver/lib/Exception/WebDriverException.php on line 154 Call Stack: 0.0005 234144 1. {main}() /home/ubuntu/workspace/php-web-driver-test/test-1.php:0 0.0020 307072 2. Facebook\WebDriver\Remote\RemoteWebDriver::create() /home/ubuntu/workspace/php-web-driver-test/test-1.php:11 0.0030 387224 3. Facebook\WebDriver\Remote\HttpCommandExecutor->execute() /home/ubuntu/workspace/php-web-driver-test/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:126 0.1971 486960 4. Facebook\WebDriver\Exception\WebDriverException::throwException() /home/ubuntu/workspace/php-web-driver-test/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php:320
Also there is some response from Selenium Server:
06:04:33.192 INFO [GridLauncherV3.launch] - Selenium build info: version: '3.12.0', revision: '7c6e0b3'
06:04:33.194 INFO [GridLauncherV3$1.launch] - Launching a standalone Selenium Server on port 4444
2018-05-16 06:04:33.330:INFO::main: Logging initialized #566ms to org.seleniumhq.jetty9.util.log.StdErrLog
06:04:33.641 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
06:04:42.085 INFO [ActiveSessionFactory.apply] - Capabilities are: Capabilities {browserName: chrome}
06:04:42.088 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
I don't know why such an error occurs, may be I have to force browser headless mode option or specify exact firefox or chrome location for web driver?
In my ubuntu 16.04, When i run php webdriver sample, it open selenium home page, and in console it throws following error
PHP Fatal error: Uncaught Facebook\WebDriver\Exception\UnrecognizedExceptionException: Failed to convert secure to boolean
Build info: version: '3.5.3', revision: 'a88d25fe6b', time: '2017-08-29T12:54:15.039Z'
System info: host: 'nest-aspire-e5-575', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.10.0-32-generic', java.version: '1.8.0_144'
Driver info: driver.version: unknown in /home/nest/selenium/vendor/facebook/webdriver/lib/Exception/WebDriverException.php:158
Stack trace: #0 /home/nest/selenium/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php(320): Facebook\WebDriver\Exception\WebDriverException::throwException(61, 'Failed to conve...', Array) #1 /home/nest/selenium/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php(535): Facebook\WebDriver\Remote\HttpCommandExecutor->execute(Object(Facebook\WebDriver\Remote\WebDriverCommand)) #2 /home/nest/selenium/vendor/facebook/webdriver/lib/Remote/RemoteExecuteMethod.php(40): Facebook\WebDriver\Remote\RemoteWebDriver->e in /home/nest/selenium/vendor/facebook/webdriver/lib/Exception/WebDriverException.php on line 158
Configuration
PHP 7.0.22-0ubuntu0.16.04.1 (cli) ( NTS )
Firefox 55.0.2 (64-bit)
geckodriver-v0.18.0-linux64
selenium-server-standalone-3.5.3
Output of java -Dwebdriver.gecko.driver="/home/nest/selenium/geckodriver" -jar selenium-server-standalone-3.5.3.jar
06:48:12.855 INFO - Selenium build info: version: '3.5.3', revision: 'a88d25fe6b'
06:48:12.856 INFO - Launching a standalone Selenium Server
2017-09-10 06:48:12.872:INFO::main: Logging initialized #223ms to org.seleniumhq.jetty9.util.log.StdErrLog
06:48:12.916 INFO - Driver class not found: com.opera.core.systems.OperaDriver
06:48:12.940 INFO - Driver provider class org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}] does not match the current platform LINUX
06:48:12.940 INFO - Driver provider class org.openqa.selenium.edge.EdgeDriver registration is skipped:
registration capabilities Capabilities [{browserName=MicrosoftEdge, version=, platform=WINDOWS}] does not match the current platform LINUX
06:48:12.940 INFO - Driver provider class org.openqa.selenium.safari.SafariDriver registration is skipped:
registration capabilities Capabilities [{browserName=safari, version=, platform=MAC}] does not match the current platform LINUX
06:48:12.962 INFO - Using the passthrough mode handler
2017-09-10 06:48:12.986:INFO:osjs.Server:main: jetty-9.4.5.v20170502
2017-09-10 06:48:13.017:WARN:osjs.SecurityHandler:main: ServletContext#o.s.j.s.ServletContextHandler#18eed359{/,null,STARTING} has uncovered http methods for path: /
2017-09-10 06:48:13.021:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler#18eed359{/,null,AVAILABLE}
2017-09-10 06:48:13.034:INFO:osjs.AbstractConnector:main: Started ServerConnector#1c7348f{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
2017-09-10 06:48:13.035:INFO:osjs.Server:main: Started #386ms
06:48:13.035 INFO - Selenium Server is up and running
2017-09-10 06:48:29.920:INFO:osjshC.ROOT:qtp1227229563-10: org.openqa.selenium.remote.server.WebDriverServlet-1d057a39: Initialising WebDriverServlet
06:48:29.991 INFO - Binding default provider to: org.openqa.selenium.chrome.ChromeDriverService
06:48:29.992 INFO - Found handler: org.openqa.selenium.remote.server.BeginSession#4c16c489
06:48:29.995 INFO - /session: Executing POST on /session (handler: BeginSession)
06:48:30.056 INFO - Capabilities are: Capabilities {browserName=firefox, platformName=ANY, platform=ANY, firefox_profile=UEsDBBQAAAAAAA42Kkvf9RXUMgA..., }
06:48:30.057 INFO - Capabilities {browserName=firefox, platformName=ANY, platform=ANY, firefox_profile=UEsDBBQAAAAAAA42Kkvf9RXUMgA..., } matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.firefox.GeckoDriverService)
06:48:30.057 INFO - Capabilities {browserName=firefox, platformName=ANY, platform=ANY, firefox_profile=UEsDBBQAAAAAAA42Kkvf9RXUMgA..., } matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
1505006310485 geckodriver INFO geckodriver 0.18.0
1505006310509 geckodriver INFO Listening on 127.0.0.1:11793
1505006311757 geckodriver::marionette INFO Starting browser /usr/bin/firefox with args ["-marionette"]
1505006312726 Marionette INFO Enabled via --marionette
1505006316997 Marionette INFO Listening on port 38555
JavaScript error: chrome://marionette/content/server.js, line 337: NS_ERROR_SOCKET_ADDRESS_IN_USE: Component returned failure code: 0x804b0036 (NS_ERROR_SOCKET_ADDRESS_IN_USE) [nsIServerSocket.initSpecialConnection]
1505006317173 Marionette DEBUG loaded listener.js
06:48:37.478 INFO - Found handler: org.openqa.selenium.remote.server.ServicedSession#51dd308a
06:48:37.480 INFO - Handler thread for session 8505af40-68e2-4bb2-9b42-86e6ee81309f (firefox): Executing POST on /session/8505af40-68e2-4bb2-9b42-86e6ee81309f/url (handler: ServicedSession)
1505006317551 Marionette DEBUG Received DOM event "beforeunload" for "about:blank"
1505006318275 Marionette DEBUG Received DOM event "pagehide" for "about:blank"
1505006318277 Marionette DEBUG Received DOM event "unload" for "about:blank"
1505006319120 Marionette DEBUG Received DOM event "DOMContentLoaded" for "http://www.seleniumhq.org/"
1505006320699 Marionette DEBUG Received DOM event "pageshow" for "http://www.seleniumhq.org/"
06:48:40.802 INFO - Found handler: org.openqa.selenium.remote.server.ServicedSession#51dd308a
06:48:40.804 INFO - Handler thread for session 8505af40-68e2-4bb2-9b42-86e6ee81309f (firefox): Executing DELETE on /session/8505af40-68e2-4bb2-9b42-86e6ee81309f/cookie (handler: ServicedSession)
06:48:40.870 INFO - Found handler: org.openqa.selenium.remote.server.ServicedSession#51dd308a
06:48:40.872 INFO - Handler thread for session 8505af40-68e2-4bb2-9b42-86e6ee81309f (firefox): Executing POST on /session/8505af40-68e2-4bb2-9b42-86e6ee81309f/cookie (handler: ServicedSession)
You have to set the path of geckodriver I guess:
java -Dwebdriver.gecko.driver="C:\Users\Dev\geckodriver-v0.11.1\geckodriver.exe" -jar C:\wamp\bin\php
\php5.6.25\selenium-server-standalone-3.0.1.jar
I'm using Selenium server (2.39.0) on centOs server 6.5 (redhat)
developing tests in PHP, using phpUnit (i installed phpunit by pear as well)
but everytime i get this error:
Invalid response while accessing the Selenium Server at 'http://localhost:4444/selenium-server/driver/':
Failed to start new browser session: org.openqa.selenium.server.RemoteCommandException:
Error while launching browser
Caused by
RuntimeException:
Invalid response while accessing the Selenium Server at 'http://localhost:4444/selenium-server/driver/':
Failed to start new browser session: org.openqa.selenium.server.RemoteCommandException:
Error while launching browser
this is the test that i'm trying to execute:
<?php
require_once 'PHPUnit/Extensions/SeleniumTestCase.php';
class Example extends PHPUnit_Extensions_SeleniumTestCase
{
function setUp()
{
$this->setBrowser("*firefox");
$this->setBrowserUrl("http://www.google.com/");
}
function testMyTestCase()
{
$this->open("/");
$this->type("q", "selenium rc");
$this->click("btnG");
$this->waitForPageToLoad("30000");
$this->assertTrue($this->isTextPresent("Results * for selenium rc"));
}
}
?>
i'm trying also to run the script using :
phpunit --configuration conf.xml example.php
where in conf.xml i've got:
<browser name="Firefox" browser="*firefox" host="IPHOST" port="4444" timeout="30000" />
but i receive the same error
and the door 4444 is free:
netstat -anp | grep 4444
gives:
tcp 0 0 :::4444 :::* LISTEN
what am i doing wrong?
EDIT:
#sircapsalot: do you mean to change the script?
anyway i don't know if i'm going to the right direction but i changed something:
first of all the script is different:
<?php
class Example extends PHPUnit_Extensions_Selenium2TestCase
{
protected function setUp()
{
$this->setBrowser('firefox');
$this->setBrowserUrl('http://www.example.com/');
}
public function testTitle()
{
$this->url('http://www.example.com/');
$this->assertEquals('Example WWW page', $this->title());
}
}
?>
and i installed Xvfb
so now i don't have the error that selenium has failed to start new browser session,
but i'm having another error
PHPUnit_Extensions_Selenium2TestCase_WebDriverException:
Unable to connect to host 127.0.0.1 on port 7055 after 45000ms.
Firefox console output:
Error: no display specified
and i already tried with:
Xvfb :99 -ac -screen 0 1280x1024x24 &
and:
export DISPLAY=:99
i've fixed the "no display specified" error, the mistake was that selenium server was already running when i was starting Xvfb,
so this are the steps (after Xvfb and selenium installation):
run Xvfb ( Xvfb :99 -ac -screen 0 1280x1024x24 & )
export display ( export DISPLAY=:99 )
run selenium ( java -jar selenium-server-standalone-versionNumber.jar )
run script ( phpunit namefile.php )
if selenium is already running you can stop it by:
localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer
now the script works
I have got a test case in my test class and some problems with it. I run the script from console. The script is executed to a certain point and then the test fails with error:
Could not connect to the Selenium RC server.
Here is log from console:
PHPUnit 3.5.15 by Sebastian Bergmann.
E
Time: 01:56, Memory: 4.00Mb
There was 1 error:
1) someTest::testSomething
PHPUnit_Framework_Exception: Could not connect to the Selenium RC server.
/var/www/path.../someTest.php:105
FAILURES!
Tests: 1, Assertions: 0, Errors: 1.
Line 105 in my test script:
$this->clickAndWait("//a[text()='Next']");
And here is Selenium log:
14:00:40.983 INFO - Command request: click[//a[text()='Next'], ] on session 4222e17607254f41a6a52e13d0fd7cc5
14:00:41.205 INFO - Got result: OK on session 4222e17607254f41a6a52e13d0fd7cc5
14:00:41.207 INFO - Command request: waitForPageToLoad[600000000, ] on session 4222e17607254f41a6a52e13d0fd7cc5
14:02:11.328 INFO - Command request: testComplete[, ] on session 4222e17607254f41a6a52e13d0fd7cc5
14:02:11.328 INFO - Killing Firefox...
14:02:11.506 INFO - Got result: ERROR: Got a null result on session 4222e17607254f41a6a52e13d0fd7cc5
14:02:11.508 INFO - Got result: OK on session
I tried with Selenium Server Standalone 2.19.0, then with 2.20.0 - the same result.
The server is still running, even after test interruption.
My question is:
why this error occurs suddenly and unexpectedly interrupts the script?
PHPUnit 3.5.15
Selenium Server Standalone 2.19.0 & 2.20.0
Firefox 3.6.18
Ubuntu 10.04
Try with $this->click("link=Next");
The reason behind this, When selenium try to find a text and the page is not fully loaded or there are ambiguous text then selenium throws it and shows like "Could not connect to the Selenium RC server". verification/assertion of text is making problem some times.