2013-03-12 125 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