0

I'm trying to get started using Selenium with Chrome, i've had no previous trouble dealing with Selenium+Firefox, but i cannot seem to launch a Chrome browser now - every time I try, a Firefox browser appears instead.

Here is my setup:

$web_driver = new ChromeDriver("C:\chromedriver\chromedriver.exe");
$session = $web_driver->session('chrome');

I realise the first line is likely not to be correct. But i cannot think of how else to initiate Chrome.

Note: I have already downloaded the chrome web driver.

Here are the sources i used: http://edvanbeinum.com/using-selenium-2-phpunit-to-automate-browser-testing https://code.google.com/p/selenium/wiki/ChromeDriver

Many thanks.

1
  • What other code are you using (post it's entirety, or at least trim it down to the fewest lines possible) Commented Mar 12, 2013 at 17:25

2 Answers 2

1

Try using

 $session = $web_driver->session('googlechrome');

instead of

 $session = $web_driver->session('chrome');
Sign up to request clarification or add additional context in comments.

Comments

0

You might want to take a look here and here.

$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);

1 Comment

A code block alone does not provide a good answer. Please add explanations (why it solve the issue, where was the mistake, etc...)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.