I
I
ideological2016-06-13 16:29:40
PHP
ideological, 2016-06-13 16:29:40

How to properly run Selenium on a VPS?

Please tell me about the correct launch of Selenium on a remote machine with Debian.
I just do:

java -jar selenium-server-standalone-2.53.0.jar -Dwebdriver.chrome.driver=chromedriver

And a page appears at the url http://[my_ip]:4444/wd/hub . Which seems to be good.
I installed via Composer https://github.com/facebook/php-webdriver
and I am running code like this:
<?php
// Указываем пространство имен
namespace Facebook\WebDriver;

// Указываем какие классы будут использоватся
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;

//Пподключаем автолоадер классов
require_once('vendor/autoload.php');

// Задаем хост на котором запущен Selenium (localhost - если же на этом компьютере) и номер порта (4444 - порт по умолчанию, если мы не задали другой)
$host = 'http://[мой_ip]:4444/wd/hub';

$driver = RemoteWebDriver::create($host, DesiredCapabilities::chrome());

//  Подаем команду браузеру переход на URL: 'http://docs.seleniumhq.org/'
$driver->get('http://docs.seleniumhq.org/');

and i get an error
Fatal error: Uncaught exception 'Facebook\WebDriver\Exception\WebDriverCurlException' with message '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' in /var/www/dfbdfb/data/www/mysite.ru/vendor/facebook/webdriver/lib/Exception/WebDriverException.php:89 Stack trace: #0 / var/www/dfbdfb/data/www/mysite.ru/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php(254): Facebook\WebDriver\Exception\WebDriverException::throwException(-1, 'Curl error thro. ..', Array) #1 /var/www/dfbdfb/data/www/mysite.ru/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php(97): Facebook\WebDriver\Remote\HttpCommandExecutor->execute(Object(Facebook\WebDriver\Remote\WebDriverCommand)) #2 /var/www/dfbdfb/data/www/mysite.ru/ucheba_test.php(15): Facebook\WebDriver\Remote\RemoteWebDriver::create('http://95.46.11... ', Object(Facebook\WebDriver\Remote\DesiredCapabilities)) #3 {main} thrown in /var/www/dfbdfb/data/www/mysite.ru/vendor/facebook/webdriver /lib/Exception/WebDriverException.php on line 89
What am I doing wrong?
Perhaps you need chrome to be open on the VPS at the time of launch? But I don’t know how to do it, unfortunately (. Or this is not the problem at all.
Tell me how to start it correctly?
Moreover, after closing the console, Selenium will disappear, is it all somehow written to autoload?
In general, I would be very grateful for clarifications; ). No articles were found.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Danil Biryukov-Romanov, 2016-06-14
@ideological

Selenium is running without a monitor - the browser can't start and I get this error.
To run full browsers on a VPS, you can use xvfb-run. As an example run:
Read more about this article:
ermin.ru/post/19

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question