Skip to content

Fatal error: Uncaught exception  #480

@mizanphp

Description

@mizanphp

What are you trying to achieve? (Expected behavior)

I want to run example.php
I want to see how automatically open my Firefox browser and work according to example.php files code.

What do you get instead? (Actual behavior)

I got below error.
Fatal error: Uncaught exception 'Facebook\WebDriver\Exception\UnrecognizedExceptionException' with message 'Failed to convert secure to boolean Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T16:15:40.131Z' System info: host: 'FICTIONSOFTCEO', ip: '192.168.0.103', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '9' Driver info: driver.version: unknown' in D:\xampp1\htdocs\php-webdriver\lib\Exception\WebDriverException.php:158 Stack trace: #0 D:\xampp1\htdocs\php-webdriver\lib\Remote\HttpCommandExecutor.php(320): Facebook\WebDriver\Exception\WebDriverException::throwException(61, 'Failed to conve...', Array) #1 D:\xampp1\htdocs\php-webdriver\lib\Remote\RemoteWebDriver.php(535): Facebook\WebDriver\Remote\HttpCommandExecutor->execute(Object(Facebook\WebDriver\Remote\WebDriverCommand)) #2 D:\xampp1\htdocs\php-webdriver\lib\Remote\RemoteExecuteMethod.php(40): Facebook\WebDriver\Remote\RemoteWebDriver->execute('addCookie', Array) #3 D:\xampp1\htdocs\php-webdriver\lib\WebDriverOpt in D:\xampp1\htdocs\php-webdriver\lib\Exception\WebDriverException.php on line 158

How could the issue be reproduced? (Steps to reproduce)

Step 1: I have cloned this project (facebook/php-webdriver)
$ git clone https://github.com/facebook/php-webdriver.git

Step 2: I have installed the library
$ composer require facebook/webdriver

Step 3: I have downloaded selenium server latest version from http://selenium-release.storage.googleapis.com/index.html
Downloaded file: selenium-server-standalone-3.6.0.jar

Step 4: I have downloaded the geckodriver from https://github.com/mozilla/geckodriver/releases
Downloaded file: geckodriver-v0.19.0-win64.zip
Then extract it and double click to execute

Step 5: I have opened CMD go to project directory and run the server using following command
java -jar selenium-server-standalone-3.6.0.jar
Selenium server is up and running

Step 6: I have execute my example.php script in firefox browser.
URL : http://localhost/php-webdriver/example.php
When i press enter new browser is just opening with the url http://www.seleniumhq.org/ and i am getting error message mentioned above.

<?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();
$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();

Details

  • Php-webdriver version: v1.4.1
  • PHP version: 5.6.31 (VC11 X86 32bit thread safe) + PEAR
  • Selenium server version: 3.6.0
  • Operating system: Windows 7 64 bit
  • Browser used + version: Firefox 56.0 (32-bit)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions