V
V
Vlad Pasechnik2015-11-29 01:23:02
PHP
Vlad Pasechnik, 2015-11-29 01:23:02

How to set up a virtual browser (Selenium) in PHP?

Hello, has anyone worked with Selenium in PHP?
Can't figure out the initial setup.
I run java -Dwebdriver.chrome.driver=chromedriver -jar selenium-server-standalone-2.48.2.jar I
use the package https://github.com/facebook/php-webdriver
I execute similar lines

use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;

$host = 'http://localhost:4444/wd/hub'; // this is the default
$desired_capabilities = DesiredCapabilities::chrome();
$driver = RemoteWebDriver::create($host, $desired_capabilities);
$driver->get('https://google.com');
$title = $driver->getTitle();

Issues
Facebook\WebDriver\Exception\WebDriverCurlException
Curl error thrown for http POST to /session with params: {"desiredCapabilities":{"browserName":"chrome","platform":"ANY"}}
Operation timed out after 30001 milliseconds with 0 bytes received

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vasya Pupkin, 2015-11-29
@jumper423

If there are no error messages after running
in another SSH window, check that it has started
. Try replacing localhost with 127.0. like on modern systems localhost means ::1, there is a suspicion that there are problems with ipv6.
Also try adding flags to parse the error:

java -Dwebdriver.chrome.driver=chromedriver -Dwebdriver.chrome.args="--logging-level=3" -jar selenium-server-standalone-2.48.2.jar --verbose

I
ideological, 2016-06-13
@ideological

How was the problem resolved?
Exactly the same question How to properly run Selenium on a VPS?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question