forked from php-webdriver/php-webdriver
-
Notifications
You must be signed in to change notification settings - Fork 0
ChromeDriver
starrychloe edited this page Mar 27, 2015
·
3 revisions
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.
<?php
putenv("webdriver.chrome.driver=/path/to/chromedriver");
$driver = ChromeDriver::start();
###How to get Chrome driver and set the download directory
If you have chromedriver.exe in the path or the same directory that Selenium is running, then you don't need to set any variables. If you have chromedriver.exe elsewhere, you can start Selenium with $ java -jar selenium-server-standalone-2.45.0.jar -Dwebdriver.chrome.driver=/path/to/chromedriver.exe
$host = 'http://localhost:4444/wd/hub'; // this is the default
$capabilities = DesiredCapabilities::htmlUnitWithJS();
{
// For Chrome
$options = new ChromeOptions();
$prefs = array('download.default_directory' => 'c:/temp');
$options->setExperimentalOption('prefs', $prefs);
$capabilities = DesiredCapabilities::chrome();
$capabilities->setCapability(ChromeOptions::CAPABILITY, $options);
}
$driver = RemoteWebDriver::create($host, $capabilities, 5000);