2013-03-12 152 views
0

我想开始使用Selenium与Chrome,我以前没有处理Selenium + Firefox的麻烦,但我现在似乎无法启动Chrome浏览器 - 每当我尝试时, Firefox浏览器出现。Selenium PHP Chrome Web驱动程序问题

这里是我的设置:

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

我认识的第一行很可能不正确。但我想不出如何启动Chrome。

注意:我已经下载了chrome web驱动程序。

下面是我使用的来源: http://edvanbeinum.com/using-selenium-2-phpunit-to-automate-browser-testing https://code.google.com/p/selenium/wiki/ChromeDriver

非常感谢。

+0

哪些是您使用的代码(后它的全部,或者至少修剪下来到线尽可能少的) – Arran 2013-03-12 17:25:26

回答

1

尝试使用

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

代替

$session = $web_driver->session('chrome'); 
0

你可能想看看herehere

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

代码块本身并不能提供一个很好的答案。请添加解释(为什么它解决了问题,错误在哪里等) – 2016-01-06 13:22:42