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

Support the W3C WebDriver-compliant capabilities and protocol in Selenium > 3.10 #31

Open
fatso83 opened this issue May 20, 2021 · 2 comments

Comments

@fatso83
Copy link

fatso83 commented May 20, 2021

All newer browsers support the W3C WebDriver-compliant capabilities and protocol featured in Selenium versions 3.11 and higher. As for the case of Safari, it has actually dropped support for the JSON Wire Protocol already (starting with Safari 12.1).

Background article on Sauce Labs: https://wiki.saucelabs.com/display/DOCS/W3C+Capabilities+Support

I think we should consider either fully converting to this new protocol (as the old will be dropped) or support it using a flag. AFAIK it seems we only need to change these lines:
https://github.com/mantoni/min-webdriver/blob/master/lib/driver.js#L202-L224

It might not be more than a few prop renames, it seems. (Famous last words)

@fatso83
Copy link
Author

fatso83 commented May 25, 2021

So, basically I was not able to get this going. No matter what I tried I did not get past this:

POST /wd/hub/session

Unexpected HTTP status: 401 Unauthorized

transfer-encoding: chunked
date: Tue, 25 May 2021 10:59:25 GMT
connection: close
content-type: text/plain
www-authenticate: Basic realm="Sauce OnDemand"
server: monocle/0.42

Response Status Code: 13
Response Message:
    Misconfigured -- Sauce Labs Authentication Error.
    You used username 'None' and access key 'None' to authenticate, which are not valid Sauce Labs credentials.

    The following desired capabilities were received:
    {'accessKey': 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXbd2851f8',
     'browserName': 'Safari',
     'javascriptEnabled': True,
     'platformName': 'macOS',
     'username': 'sinonjs'}


Error: Unexpected HTTP status: 401 Unauthorized

I linked up this project to sinon and used that as the driver. Basically, I am not sure what the "wire protocol" looks like, but I know the structure is a bit different than simply prop renaming, after inspecting the actual webdriver library for Node.

I first had a look at this:
https://github.com/saucelabs-training/w3c-examples/blob/master/node/mocha/test/chrome-w3c-example-test.js

Then inspected https://github.com/SeleniumHQ/selenium/blob/7b832ead31f41304f0fa73ef4c6902c2ef1651e6/javascript/node/selenium-webdriver/lib/webdriver.js#L712

Saw that the capabilities now belonged in a different prop, and also under a new sub-prop. Only a subset of the previous props are allowed there, which explains why the username and access key are not recognized.

So it seems I need to change a bit more than just https://github.com/mantoni/min-webdriver/blob/master/lib/driver.js#L202-L224 ...

I guess using the offical selenium-webdriver to drive this is out of the question? It would probably handle most of the low-level details, but then again, I guess there is a specific reason why @mantoni chose to reimplement this 😃

@mantoni
Copy link
Owner

mantoni commented May 25, 2021

Thank you for digging into this. I havn't found the time myself, unfortunately.

There is only one reasons why I implemented the protocol myself: The selenium-webdriver package has 676 kB, and I needed only a handfull of requests. This package is just 35 kB.

At the time, implementing the protocol was simple enough, but it might have become more complicated over time. I'm not attached to this project and the way it works or how "heavy" it is anymore. The name prefix "min-" may not accurate anymore, if it depends on selenium-webdriver 😆.

So having said that, feel free to use whatever library makes your life easy. If you want to do this completly differently, go ahead, I'm also happy to include a different dependency in mochify. Whatever works.

mroderick added a commit to sinonjs/referee-sinon that referenced this issue Feb 21, 2022
This is not currently possible due to missing W3C spec feautre in
[min-webdriver][0]. This has been reported in [`sinon#2372`][1].

For now, let's remove Safari from the list, so we at least can test in
the other runtimes.

[0]: mantoni/min-webdriver#31
[1]: sinonjs/sinon#2372
mroderick added a commit to sinonjs/referee-sinon that referenced this issue Feb 21, 2022
This is not currently possible due to missing W3C spec feautre in
[min-webdriver][0]. This has been reported in [`sinon#2372`][1].

For now, let's remove Safari from the list, so we at least can test in
the other runtimes.

[0]: mantoni/min-webdriver#31
[1]: sinonjs/sinon#2372
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

2 participants