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

Do we need to move to newer capabilities settings? #467

Closed
lread opened this issue Jun 25, 2022 · 9 comments · Fixed by #616
Closed

Do we need to move to newer capabilities settings? #467

lread opened this issue Jun 25, 2022 · 9 comments · Fixed by #616

Comments

@lread
Copy link
Collaborator

lread commented Jun 25, 2022

Currently

While taking a peek a WebDriver logs, I noticed firefox's geckodriver emitting:

1656188404728	webdriver::command	WARN	You are using deprecated legacy session negotiation patterns (desiredCapabilities/requiredCapabilities), see https://developer.mozilla.org/en-US/docs/Web/WebDriver/Capabilities#Legacy

So maybe...

We should have a look-see and see if we should be specifying capabilities in a different way these days.

Action

I'll eventually follow up.

@lread lread changed the title Do we need to move to newer capabalities settings? Do we need to move to newer capabilities settings? Jul 4, 2022
@lread
Copy link
Collaborator Author

lread commented Feb 2, 2023

Just noticed this from ChromeDriver when looking at #519:

17:36:16.436 WARN [ProtocolHandshake.createSession] - Support for Legacy Capabilities is deprecated; You are sending the following invalid capabilities: [chromeOptions]; Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/

So that's drivers for both Firefox and Chrome emitting warnings.

I'd have to check, but the Edge driver probably does the same.

But the Safari driver is a bit of an oddball, before we update, I'd have to check we aren't breaking it.

@lread
Copy link
Collaborator Author

lread commented May 18, 2024

Here's a pretty good explanation of the current syntax: w3c/webdriver#1215 (comment)

If I understand correctly, we could probably auto-convert the legacy requiredCapabilties + desiredCapabilties to the current syntax.

Using edn and pseudo-capabilties:

{:requiredCapabilities {:some-capability :must-be-true
                        :some-config :here}
 :desiredCapabilties {:some-other-capability :should-be-preferred}}

Could become:

{:capabilities 
  {:alwaysMatch {:some-capability :must-be-true
                 :some-config :here}
   :firstMatch [{:some-other-capability :should-be-preferred}]}

@lread
Copy link
Collaborator Author

lread commented May 18, 2024

The current state of Etaoin is:

Etaoin documents that the user can specify :capabilities, but it always sends them as :desiredCapabilities on session creation. (Unless on safari, where they are sent as :capabilities (we can check if this is still a thing)).

So Etaoin does not explicitly expose the concept of required and desired capabilities.

Some thoughts

The alwaysMatch and firstMatch syntax implies that there are a bunch of candidate web drivers to match against. I think this also implies talking to a Selenium Grid WebDriver #378, which we do not support yet.

The capabilities spec design is a bit odd in that it mixes user-provided config with webdriver selection criteria. Etaoin is focused on the user-provided config aspect.

In the near term, we can experiment with using the new format while maintaining the existing behaviour. We'll see if plunking the Etaoin user-specified :capabilities under :capabilities -> :firstMatch works out on our session create payload.

Optionally, we can consider: if the user specifies :alwaysMatch and/or :firstMatch keys under :capabilties just send the capabilities as is.

@lread
Copy link
Collaborator Author

lread commented Aug 6, 2024

GeckoDriver 0.35.0 was just released with the following change:

Removed support for session negotiation using the deprecated desiredCapabilities and requiredCapabilities.

So, I'll get to this one very soon.

@lread
Copy link
Collaborator Author

lread commented Aug 6, 2024

Oh it looks like Etaoin is ultra-legacy here.

We are expressing, for example, loggingPrefs which technically pre-dates the W3C WebDriver standard was part JSON Wire Protocol era and might have been an informal and commonly supported naming rather than part of the spec?

I did find it specifically documented via the wayback machine.

So.. the new way, if I understand it, is vendor-specific.

@lread
Copy link
Collaborator Author

lread commented Aug 7, 2024

Ok, moving to the new capabilities syntax puts chromedriver in a different mode.
Some existing API calls (like get-logs) fail with Cannot call non W3C standard command while in W3C mode. You'd think W3C mode might mean that you can only call official W3C spec endpoints. You might also discover a w3c boolean vendor option which might lead you down a rabbit hole.

After too much poking around, my initial theory is that W3C mode could maybe be thought of as non-legacy-api-mode.
Chromedriver-specific endpoints work, but you need to use the non-legacy-endpoints.
For example if I update get-logs URL (an endpoint which is not in the W3C webdriver spec) I can get it to work.

Google documents its chromedriver API at the Selenium level, which is not terribly helpful to us.
To discover the REST endpoints, I'm referring to the source code.
This python client is helpful:

@lread
Copy link
Collaborator Author

lread commented Aug 7, 2024

Oh, here's maybe it: The chromedriver "W3C mode" probably is a badly named replacement for the old JSON Wire Protocol. Maybe.

@lread lread mentioned this issue Aug 7, 2024
4 tasks
@lread
Copy link
Collaborator Author

lread commented Aug 8, 2024

Sooo... my guess for the chromedriver Cannot call non W3C standard command while in W3C mode error is: hey, you said you wanted to work in w3c mode, there is a w3c webdriver spec alternative to the legacy API you are calling, use that instead.

@lread
Copy link
Collaborator Author

lread commented Aug 9, 2024

Ok, we need a breaking change to move to the w3 spec.

The w3c spec implements keyboard and mouse interaction through "actions".
A sequence of actions is expected to be sent to the WebDriver and be run as a transaction.
Etaoin's drag-and-drop feature is implemented with actions, so it works nicely.

But Etaoin also exposes (all chrome specific unless otherwise noted)

  • mouse-btn-down
  • mouse-btn-up
  • mouse-move-to (was also available in firefox)
  • with-mouse-btn
  • touch-tap
  • touch-down
  • touch-up
  • touch-move
  • mouse-click
  • left-click
  • right-click

These features cannot be migrated as is to WebDriver actions because, in the W3C spec "actions" world, they represent individual steps in a transaction and, as such, do not work well if sent to the WebDriver independently.

They will be deleted.

lread added a commit that referenced this issue Aug 11, 2024
We've been using a `capabilities` syntax for create session that has long been
deprecated. Firefox finally forced our hand with geckodriver 0.35.0,
which has removed support for the obsolete syntax.

All supported WebDrivers understand the newer syntax.

We used to pass capabilities in as `desiredCapabilities`,
we now pass them in as a single item in the `firstMatch` vector.
This should match existing behaviour.

Moving to the new capabilities syntax tells `chromedriver`
(and `msedgedriver`) that we are running in "w3c mode". This has benefits on
Etaoin code. Our many customizations for these WebDrivers are no longer
necessary, they now support the W3C WebDriver endpoint spec.

In "w3c mode", chromedriver disallows any endpoints that could be served
by W3C WebDriver endpoints.

Notable examples are mouse and touch operations. These are now
handled by the W3C WebDriver action endpoints. WebDriver actions are not
stand-alone, they are submitted as transaction of steps. As such the
following Chrome-specific fns are no longer needed and would be confusing
if not deleted:

- `mouse-btn-down`
- `mouse-btn-up`
- `with-mouse-btn`
- `mouse-move-to` (was also available in Firefox)
- `mouse-click`
- `right-click`
- `left-click`
- `touch-down`
- `touch-move`
- `touch-up`

Users will instead express these manipulations via the existing
`perform-actions`.

Fns that represent a transaction of actions in themselves remain:
- `drag-and-drop` (from element to element)
- `double-click*` (on an element)
- `*-click-on` (on an element)
- `touch-tap` (on an element)

Verifying that everything worked required a full review of the API.

Some sweeping changes:
- Our recent deletion of PhantomJS support allowed me to streamline many
`defmulti`s into `defn`s.
- Added links to W3C WebDriver Spec endpoints to docstrings

Added some fns to expose at the W3C WebDriver Spec granularity:
- `get-timeouts`
- `set-timeouts`
- `get-element-rect`
- `get-element-rect-el`
- `get-element-rect`
- `set-window-rect`
- `get-window-rect`

We have finer grained versions of the above (ex. `get-element-position`,
`get-element-size`, etc). We've kept these for backwards compatibility,
but if we were starting today, we would have just matched today's W3C
WebDriver spec.

Minor fixes/changes:
- Uncomment and fix the maximize test
- Screenshots on elements work on safari, enable them
- Added notes on displayedness to docstrings
- Remove internal support for undocumented `:desired-capabilities`, the implementation
was either ultra legacy or misunderstood legacy APIs.

Add `bb test-coverage` task to check what we are not covering with tests

New tests include coverage for:
- `back`
- `forward`
- `set-cookie`
- `release-actions`
- `*-timeout*`
- `double-click`

Closes #467

Incidentally closes #522 via better docstrings on getting properties.

Closes #484 with W3C WebDriver spec endpoint links.
@lread lread mentioned this issue Aug 11, 2024
4 tasks
lread added a commit that referenced this issue Aug 12, 2024
* Move to w3c WebDriver spec

We've been using a `capabilities` syntax for create session that has long been
deprecated. Firefox finally forced our hand with geckodriver 0.35.0,
which has removed support for the obsolete syntax.

All supported WebDrivers understand the newer syntax.

We used to pass capabilities in as `desiredCapabilities`,
we now pass them in as a single item in the `firstMatch` vector.
This should match existing behaviour.

Moving to the new capabilities syntax tells `chromedriver`
(and `msedgedriver`) that we are running in "w3c mode". This has benefits on
Etaoin code. Our many customizations for these WebDrivers are no longer
necessary, they now support the W3C WebDriver endpoint spec.

In "w3c mode", chromedriver disallows any endpoints that could be served
by W3C WebDriver endpoints.

Notable examples are mouse and touch operations. These are now
handled by the W3C WebDriver action endpoints. WebDriver actions are not
stand-alone, they are submitted as transaction of steps. As such the
following Chrome-specific fns are no longer needed and would be confusing
if not deleted:

- `mouse-btn-down`
- `mouse-btn-up`
- `with-mouse-btn`
- `mouse-move-to` (was also available in Firefox)
- `mouse-click`
- `right-click`
- `left-click`
- `touch-down`
- `touch-move`
- `touch-up`

Users will instead express these manipulations via the existing
`perform-actions`.

Fns that represent a transaction of actions in themselves remain:
- `drag-and-drop` (from element to element)
- `double-click*` (on an element)
- `*-click-on` (on an element)
- `touch-tap` (on an element)

Verifying that everything worked required a full review of the API.

Some sweeping changes:
- Our recent deletion of PhantomJS support allowed me to streamline many
`defmulti`s into `defn`s.
- Added links to W3C WebDriver Spec endpoints to docstrings

Added some fns to expose at the W3C WebDriver Spec granularity:
- `get-timeouts`
- `set-timeouts`
- `get-element-rect`
- `get-element-rect-el`
- `get-element-rect`
- `set-window-rect`
- `get-window-rect`

We have finer grained versions of the above (ex. `get-element-position`,
`get-element-size`, etc). We've kept these for backwards compatibility,
but if we were starting today, we would have just matched today's W3C
WebDriver spec.

Minor fixes/changes:
- Uncomment and fix the maximize test
- Screenshots on elements work on safari, enable them
- Added notes on displayedness to docstrings
- Remove internal support for undocumented `:desired-capabilities`, the implementation
was either ultra legacy or misunderstood legacy APIs.

Add `bb test-coverage` task to check what we are not covering with tests

New tests include coverage for:
- `back`
- `forward`
- `set-cookie`
- `release-actions`
- `*-timeout*`
- `double-click`

Closes #467

Incidentally closes #522 via better docstrings on getting properties.

Closes #484 with W3C WebDriver spec endpoint links.

* address lint error

* test: capabilities: \ path separators on win
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

Successfully merging a pull request may close this issue.

1 participant