Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start chrome without the selenium standalone server. #647

Closed
vickyssj7 opened this issue Jun 23, 2019 · 3 comments
Closed

Start chrome without the selenium standalone server. #647

vickyssj7 opened this issue Jun 23, 2019 · 3 comments

Comments

@vickyssj7
Copy link

@vickyssj7 vickyssj7 commented Jun 23, 2019

I've gone through the doc for facebook webdriver, please note I'm using latest version of everything including facebook/webdriver, chromedriver, selenium. This is what written in the doc:


You can find more information and download ChromeDriver in https://code.google.com/p/selenium/wiki/ChromeDriver. After downloading the chrome driver, we can start chrome without the selenium standalone server.

   putenv("webdriver.chrome.driver=/path/to/chromedriver");
   $driver = ChromeDriver::start();

So I tried using headless mode to run chrome, here is my code:


putenv("webdriver.chrome.driver=". __DIR__ ."/chromedriver.exe");
$driver = ChromeDriver::start();
$host = 'http://localhost:4444/wd/hub'; // this is the default
$options = new ChromeOptions();
$options->addArguments(array(
	'--headless',
	'--window-size=1280x800',
	'--disable-gpu',
	'--no-sandbox'
));

$capabilities = DesiredCapabilities::chrome(); 
$capabilities->setCapability(ChromeOptions::CAPABILITY, $options);
$driver = RemoteWebDriver::create($host, $capabilities, 5000);

$driver->get('https://web.testserver.org/');
print_r($driver);
die;

as I can see chrome is running in background but then closes by iteself, and error that I'm getting is:

Curl error thrown for http POST to /session with params: {"desiredCapabilities":{"browserName":"firefox","platform":"ANY","firefox_profile":"UEsDBAoAAAAAADVg107f9RXUMgAAADIAAAAHAAAAdXNlci5qc3VzZXJfcHJlZigicmVhZGVyLnBhcnNlLW9uLWxvYWQuZW5hYmxlZCIsIGZhbHNlKTsKUEsBAj8DCgAAAAAANWDXTt\/1FdQyAAAAMgAAAAcAAAAAAAAAAAAAALaBAAAAAHVzZXIuanNQSwUGAAAAAAEAAQA1AAAAVwAAAAAA"}}

Failed to connect to localhost port 4444: Connection refused - Line:- 297 File: F:\xamppnew\htdocs\chayenubot\vendor\facebook\webdriver\lib\Remote\HttpCommandExecutor.php

I know that you will say that you need to run selenium standalone, but I don't want to run it, as I want to run chrome without selenium to make automation. Please let me know.

@staudenmeir

This comment has been minimized.

Copy link

@staudenmeir staudenmeir commented Jun 23, 2019

Use http://localhost:9515 when you are running ChromeDriver without Selenium:

$host = 'http://localhost:9515';

Unfortunately, ChromeDriver::start() opens an empty browser window, so the test isn't really "headless".

You can use Symfony's Process class instead:

use Symfony\Component\Process\Process;

$process = new Process(__DIR__.'/chromedriver.exe');
$process->start();

$host = 'http://localhost:9515';
$options = new ChromeOptions();
$options->addArguments(array(
    '--headless',
    '--window-size=1280x800',
    '--disable-gpu',
    '--no-sandbox'
));

$capabilities = DesiredCapabilities::chrome();
$capabilities->setCapability(ChromeOptions::CAPABILITY, $options);
$driver = RemoteWebDriver::create($host, $capabilities, 5000);

$driver->get('https://web.chayenu.org/');
$driver->close();

$process->stop();
@vickyssj7

This comment has been minimized.

Copy link
Author

@vickyssj7 vickyssj7 commented Jun 24, 2019

Ok I'll check @staudenmeir , also is it possible to run bot on server whether it's linux or windows based server to run bot in headless mode to do the task.

@vickyssj7

This comment has been minimized.

Copy link
Author

@vickyssj7 vickyssj7 commented Jun 30, 2019

I tried chromedriver on ubuntu server but symfony process is not helping as I had to use xvfb to run the chromedriver in order to run the chrome in headless mode and that worked for me to make testing from ubuntu server in order to automate the process.

@vickyssj7 vickyssj7 closed this Jun 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.