2017-08-17 1 views
-1

Je crée dans mon synfony quelques tests avec PHPUnit et Facebook \ WebDriver et simplement tester le code exemplePhpUnit avec chauffeur 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(); 

Je reçois cette erreur

PHP Fatal error: Uncaught Facebook \ WebDriver \ Exception \ WebDriverCurlException: erreur Curl jeté pour http POST/Session avec params: { "desiredCapabilities": { "browserName": "Firefox", "plate-forme": "ANY", "firefox_profile": "UEsDBBQAAAAAAGGCEUvf9RXUMgAAADIAAAAHAAAAdXNlci5qc3VzZXJfcHJlZigicmVhZGVyLnBhcnNlLW9uLWxvYWQuZW5hYmxlZCIsIGZhbHNlKTsKUEsBAhQDFAAAAAAAYYIRS9/1FdQyAAAAMgAAAAcAAAAAAAAAAAAAALaBAAAAAHVzZXIuan NQSwUGAAAAAAEAAQA1AAAAVwAAAAAA "}}

Impossible de se connecter à localhost Port 4444: Connexion refusée à /var/www/html/schweppes-sf/src/main/php/vendor/facebook/webdriver/lib/Exception/WebDriverException.php: 92 trace de la pile:

0 /var/www/html/schweppes-sf/src/main/php/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php(320): Facebook \ WebDriver \ Exception \ WebDriverException :: throwException (-1, 'Erreur curl thro ...', Array)

1/var/www/html/schweppes-sf/src/main/php/vendor/facebook/webdriver/lib/Remote /RemoteWebDriver.php (100): Facebook \ WebDriver \ Remote \ HttpCommandExecutor-> execute (Objet (Facebook \ Web Driver \ distance \ WebDriverComman dans /var/www/html/schweppes-sf/src/main/php/vendor/facebook/webdriver/lib/Exception/WebDriverException.php sur la ligne 92

Je n'undestand comment y remédier , devrais-je changer l'hôte?

Répondre

0

Dans le cas où quelqu'un d'autre a ce problème c'était parce que mi sélenium-server-standalone était en panne