我创造了我的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
我不知道如何解决它,我应该改变主机?