我創造了我的synfony一些測試使用PHPUnit和Facebook \ webdriver的和公正的測試示例代碼PHPUnit的使用FB司機WebDriverCurlException
<?php
// An example of using php-webdriver.
namespace Facebook\WebDriver;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
require_once('../vendor/autoload.php');
// start Firefox with 5 second timeout
$host = 'http://localhost:4444/wd/hub'; // this is the default
$capabilities = DesiredCapabilities::firefox();
//System.setProperty("webdriver.gecko.driver", "");
$driver = RemoteWebDriver::create($host, $capabilities, 5000);
// navigate to 'http://www.seleniumhq.org/'
$driver->get('http://www.seleniumhq.org/');
// adding cookie
$driver->manage()->deleteAllCookies();
$cookie = new Cookie('cookie_name', 'cookie_value');
$driver->manage()->addCookie($cookie);
$cookies = $driver->manage()->getCookies();
print_r($cookies);
// click the link 'About'
$link = $driver->findElement(
WebDriverBy::id('menu_about')
);
$link->click();
// wait until the page is loaded
$driver->wait()->until(
WebDriverExpectedCondition::titleContains('About')
);
// print the title of the current page
echo "The title is '" . $driver->getTitle() . "'\n";
// print the URI of the current page
echo "The current URI is '" . $driver->getCurrentURL() . "'\n";
// write 'php' in the search box
$driver->findElement(WebDriverBy::id('q'))
->sendKeys('php');
// submit the form
$driver->findElement(WebDriverBy::id('submit'))
->click(); // submit() does not work in Selenium 3 because of bug
https://github.com/SeleniumHQ/selenium/issues/3398
// wait at most 10 seconds until at least one result is shown
$driver->wait(10)->until(
WebDriverExpectedCondition::presenceOfAllElementsLocatedBy(
WebDriverBy::className('gsc-result')
)
);
// close the Firefox
$driver->quit();
我得到這個錯誤
PHP致命錯誤:未捕獲的Facebook \ webdriver的\例外\ WebDriverCurlException:拋出HTTP POST到使用參數/會話捲曲錯誤:{ 「desiredCapabilities」:{ 「browserName」: 「火狐」, 「平臺」: 「ANY」, 「firefox_profile」:「UEsDBBQAAAAAAGGCEUvf9RXUMgAAADIAAAAHAAAAdXNlci5qc3VzZXJfcHJlZigicmVhZGVyLnBhcnNlLW9uLWxvYWQuZW5hYmxlZCIsIGZhbHNlKTsKUEsBAhQDFAAAAAAAYYIRS9/1FdQyAAAAMgAAAAcAAAAAAAAAAAAAALaBAAAAAHVzZXIuan NQSwUGAAAAAAEAAQA1AAAAVwAAAAAA「}}
無法連接到本地主機端口4444:連接在/var/www/html/schweppes-sf/src/main/php/vendor/facebook/webdriver/lib/Exception/WebDriverException.php拒絕: 92 堆棧跟蹤:
0 /var/www/html/schweppes-sf/src/main/php/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php(320):實\的webdriver \異常\ WebDriverException :: throwException(-1,'Curl error thro ...',Array)
1/var/www/html/schweppes-sf/src/main/php/vendor/facebook/webdriver/lib/Remote /RemoteWebDriver.php(100):Facebook \ WebDriver \ Remote \ HttpCommandExecutor-> execute(Object(Facebook \ Web驅動程序\遠程\ WebDriverComman在/var/www/html/schweppes-sf/src/main/php/vendor/facebook/webdriver/lib/Exception/WebDriverException.php在線92
我不知道如何解決它,我應該改變主機?