-
Notifications
You must be signed in to change notification settings - Fork 849
Description
What are you trying to achieve? (Expected behavior)
I was trying to test the example.php with php-webdriver, and installed the selenium server standalone 3.9.1., here is the server running info:
Failed to connect to 127.0.0.1 port 1080: Connection refused...
What do you get instead? (Actual behavior)
But I did not get the succeed, the connection was failed when I test the example.php in the command line:
PHP Fatal error: Uncaught Facebook\WebDriver\Exception\WebDriverCurlException:
Curl error thrown for http POST to /session with params: {"desiredCapabilities":
{"browserName":"chrome","platform":"ANY"}}
Failed to connect to 127.0.0.1 port 1080: Connection refused in F:\websys\web\co
\vendor\facebook\webdriver\lib\Remote\HttpCommandExecutor.php:
292
Stack trace:
#0 F:\websys\web\co\vendor\facebook\webdriver\lib\Remote\Remot
eWebDriver.php(126): Facebook\WebDriver\Remote\HttpCommandExecutor->execute(Obje
ct(Facebook\WebDriver\Remote\WebDriverCommand))
#1 F:\websys\web\co\example.php(24): Facebook\WebDriver\Remote\Re
moteWebDriver::create('http://localhos...', Object(Facebook\WebDriver\Remote\Des
iredCapabilities), 5000)
#2 {main}
thrown in F:\websys\web\co\vendor\facebook\webdriver\lib\Rem
ote\HttpCommandExecutor.php on line 292
How could the issue be reproduced? (Steps to reproduce)
// You can insert your PHP code here (or remove this block if it is not relevant for the issue).
<?php
// Copyright 2004-present Facebook. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// An example of using php-webdriver.
// Do not forget to run composer install before and also have Selenium server started and listening on port 4444.
namespace Facebook\WebDriver;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
require_once('vendor/autoload.php');
// start Chrome with 5 second timeout
$host = 'http://localhost:4444/wd/hub'; // this is the default
$capabilities = DesiredCapabilities::chrome();
$driver = RemoteWebDriver::create($host, $capabilities, 5000);
// navigate to 'http://www.seleniumhq.org/'
$driver->get('https://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') // fill the search box
->submit(); // submit the whole form
// wait at most 10 seconds until at least one result is shown
$driver->wait(10)->until(
WebDriverExpectedCondition::presenceOfAllElementsLocatedBy(
WebDriverBy::className('gsc-result')
)
);
// close the browser
$driver->quit();
### Details
<!-- Please fill relevant following versions: -->
* Php-webdriver version: 1.6.0
* PHP version: 7.1.21
* Selenium server version: 3.9.1
* Operating system: windows 7
* Browser used + version: chrome Version 71.0.3578.98 (Official Build) (64-bit)
Thank you !