Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The W3C session is never created #134

Open
aik099 opened this issue Mar 19, 2024 · 0 comments
Open

The W3C session is never created #134

aik099 opened this issue Mar 19, 2024 · 0 comments

Comments

@aik099
Copy link
Contributor

aik099 commented Mar 19, 2024

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 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant