PhpUnit与fb驱动程序WebDriverCurlException

时间:2017-08-17 14:32:18

标签: php facebook selenium phpunit

我正在使用phpunit和Facebook \ WebDriver在我的synfony中创建一些测试并只测试示例代码

<?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 \ Exception \ WebDriverCurlException:使用params将http POST发送到/ session会引发卷曲错误:{&#34; desiredCapabilities&#34;:{&#34; browserName&#34;:&# 34;火狐&#34;&#34;平台&#34;:&#34; ANY&#34;&#34; firefox_profile&#34;:&#34; UEsDBBQAAAAAAGGCEUvf9RXUMgAAADIAAAAHAAAAdXNlci5qc3VzZXJfcHJlZigicmVhZGVyLnBhcnNlLW9uLWxvYWQuZW5hYmxlZCIsIGZhbHNlKTsKUEsBAhQDFAAAAAAAYYIRS9 / 1FdQyAAAAMgAAAAcAAAAAAAAAAAAAALaBAAAAAHVzZXIuanNQSwUGAAAAAAEAAQA1AAAAVwAAAAAA&#34;}}

无法连接到localhost端口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):Facebook \ WebDriver \ Exception \ WebDriverException :: throwException( - 1,&#39;卷曲错误thro ...&#39;,Array)

1 /var/www/html/schweppes-sf/src/main/php/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php(100):Facebook \ WebDriver \ Remote \ HttpCommandExecutor-&gt; execute(对象(第92行的/var/www/html/schweppes-sf/src/main/php/vendor/facebook/webdriver/lib/Exception/WebDriverException.php中的Facebook \ WebDriver \ Remote \ WebDriverComman

我不知道如何修复它,我应该更换主机吗?

1 个答案:

答案 0 :(得分:0)

如果其他人有这个问题,那是因为mi selenium-server-standalone已经停止