Skip to content

The W3C session is never created #134

Open
@aik099

Description

@aik099

Problem 1 - incorrectly built $parameters array

Calling the \WebDriver\WebDriver::session is always attempting to create a non-W3C compatible session for Selenium 3/4.

An exception, that is thrown upon a W3C session creation attempt (which is immediately caught) looks like this:

Expected to read a START_COLLECTION but instead have: START_MAP. Last 30 characters read: {"capabilities":{"firstMatch":, next 128 characters to read: {"browserName":"chrome","name":"Behat Test","goog:chromeOptions":{"binary":"\/path\/to\/custom\/browser-binary
Build info: version: '4.17.0', revision: 'e52b1be057*'
Driver info: driver.version: unknown

The \WebDriver\WebDriver::session method arguments:

  • $browserName: chrome
  • $desiredCapabilities:
array (
  'browserName' => 'chrome',
  'name' => 'Behat Test',
  'goog:chromeOptions' => array (
    'binary' => '/path/to/custom/browser-binary,
  ),
)
  • $requiredCapabilities: null

Solution

Replace

// default to W3C WebDriver API
$firstMatch = $desiredCapabilities ?: array();
$firstMatch[] = array('browserName' => Browser::CHROME);

with

$firstMatch = $desiredCapabilities ? array($desiredCapabilities) : array();
$firstMatch[] = array('browserName' => Browser::CHROME);

Done in #135.

Problem 2 - the non-W3C capabilities aren't converted to W3C capabilities

After fixing the above problem the exception message is now different:

Illegal key values seen in w3c capabilities: [name]

Solution

Covert desired/required capabilities array using an approach similar to https://github.com/php-webdriver/php-webdriver/blob/5d8e66ff849b5614015d35e99d759252e371ce26/lib/Remote/DesiredCapabilities.php#L206-L265 .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions