-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
- Loading branch information
Showing
13 changed files
with
841 additions
and
948 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,7 +173,7 @@ Edge and `msedgedriver` must match so you might need to specify the version: | |
`scoop install [email protected]` | ||
** Download: link:{url-edge-dl}[Official Microsoft download site] | ||
|
||
Check your WebDriver installations launching by launching these commands. | ||
Check your WebDriver installations by launching these commands. | ||
Each should start a process that includes its own local HTTP server. | ||
Use Ctrl-C to terminate. | ||
|
||
|
@@ -190,7 +190,7 @@ You can optionally run the Etaoin test suite to verify your installation. | |
TIP: Some Etaoin API tests rely on ImageMagick. | ||
Install it prior to running test. | ||
|
||
From a clone of the https://github.com/clj-commons/etaoin[Etaoin GitHub repo] | ||
From a clone of the https://github.com/clj-commons/etaoin[Etaoin GitHub repo]: | ||
|
||
* To check tools of interest to Etaoin: | ||
+ | ||
|
@@ -333,7 +333,7 @@ A portion of the above rewritten with `doto`: | |
---- | ||
|
||
== Playing Along in your REPL | ||
We encourage you to try the examples in from this user guide in your REPL. | ||
We encourage you to try the examples from this user guide in your REPL. | ||
|
||
The Interwebs is constantly changing. | ||
This makes testing against live sites impractical. | ||
|
@@ -385,7 +385,7 @@ into: | |
;; => ["username2" "pass2" "some text2"] | ||
---- | ||
|
||
If any exception occurs during a browser session, the WebDriver process might hang until you kill it manually. | ||
If any exception occurs during a browser session, the WebDriver process might hang around until you kill it manually. | ||
To prevent that, we recommend the `with-<browser>` macros: | ||
|
||
[source,clojure] | ||
|
@@ -939,7 +939,7 @@ The `query-shadow-root-el` and `query-all-shadow-root-el` allow you to specify t | |
(def shadow-root (e/get-element-shadow-root-el driver host)) | ||
(e/get-element-text-el driver (e/query-shadow-root-el driver shadow-root {:css "#in-shadow"})) | ||
;; => "I'm in the shadow DOM" | ||
(->> (e/query-all-shadow-root-el driver shadow-root {:css "span"}) | ||
(map #(e/get-element-text-el driver %))) | ||
;; > ("I'm in the shadow DOM" "I'm also in the shadow DOM") | ||
|
@@ -1069,17 +1069,7 @@ It can be used, for example, to check your handling of disallowing multiple form | |
(e/double-click driver {:tag :button :name "submit"}) | ||
---- | ||
|
||
There are also "blind" clicking functions. | ||
They trigger mouse clicks on the current mouse position: | ||
|
||
[source,clojure] | ||
---- | ||
(e/left-click driver) | ||
(e/middle-click driver) | ||
(e/right-click driver) | ||
---- | ||
|
||
Another set of functions do the same but move the mouse pointer to a specified element before clicking on them: | ||
Functions that move the mouse pointer to a specified element before clicking on it: | ||
|
||
[source,clojure] | ||
---- | ||
|
@@ -1575,7 +1565,7 @@ The `:eager` option only works with Firefox at the moment. | |
|
||
Etaoin supports link:{actions}[Webdriver Actions]. | ||
They are described as "virtual input devices". | ||
They act as little device input scripts that run simultaneously. | ||
They act as little device input scripts that can even be run simultaneously. | ||
|
||
Here, in raw form, we have an example of two actions. | ||
One controls the keyboard, the other the pointer (mouse). | ||
|
@@ -2315,6 +2305,8 @@ From least to most verbose: | |
* `:debug` | ||
* `:all` for all messages. | ||
|
||
Applies to Chrome and Edge only. | ||
|
||
See <<console-logs>> | ||
|
||
[id=opt-driver-log-level,reftext=`:driver-log-level`] | ||
|
@@ -2473,9 +2465,9 @@ _Default:_ <not set> | |
|
||
_Example:_ See <<http-proxy>> for an example usage. | ||
|
||
A *WebDriver*'s capabilities can be vendor specific and define preferred options. | ||
A *WebDriver*'s capabilities can be vendor-specific and define preferred options. | ||
Read WebDriver vendor docs before setting anything here. | ||
While reading docs, note that Etaoin passes along `:capabilities` as `desiredCapabilties`. | ||
While reading docs, note that Etaoin passes along `:capabilities` under `firstMatch`. | ||
|
||
=== Using Headless Drivers [[headless]] | ||
|
||
|
@@ -2489,7 +2481,7 @@ Running without a UI is helpful when: | |
Ensure your browser supports headless mode by checking if it accepts `--headless` command-line argument when running it from the terminal. | ||
|
||
When starting a driver, pass the `:headless` boolean flag to switch into headless mode. | ||
This flag is ignored for Safari which, as of June 2022, still does not support headless mode. | ||
This flag is ignored for Safari which, as of August 2024, still does not support headless mode. | ||
|
||
//{:test-doc-blocks/test-ns user-guide-headless-test} | ||
[source,clojure] | ||
|
@@ -2566,7 +2558,7 @@ To specify a directory where the browser should download files, use the `:downlo | |
---- | ||
|
||
Now, when you click on a download link, the file will be saved to that folder. | ||
Currently, only Chrome and Firefox are supported. | ||
Currently, only Chrome, Edge and Firefox are supported. | ||
|
||
Firefox requires specifying MIME-types of the files that should be downloaded without showing a system dialog. | ||
By default, when the `:download-dir` parameter is passed, the library adds the most common MIME-types: archives, media files, office documents, etc. | ||
|
@@ -2598,7 +2590,7 @@ Set a custom `User-Agent` header with the `:user-agent` option when creating a d | |
---- | ||
|
||
Setting this header is important when using <<headless,headless browsers>> as many websites implement some sort of blocking when the User-Agent includes the "headless" string. | ||
This can lead to 403 response or some weird behavior of the site. | ||
This can lead to 403 responses or some weird behavior of the site. | ||
|
||
=== HTTP Proxy [[http-proxy]] | ||
|
||
|
@@ -2622,7 +2614,7 @@ To set proxy settings use environment variables `HTTP_PROXY`/`HTTPS_PROXY` or pa | |
NOTE: A `:pac-url` is for a https://en.wikipedia.org/wiki/Proxy_auto-config#The_PAC_File[proxy autoconfiguration file]. | ||
Used with Safari as other proxy options do not work in Safari. | ||
|
||
To fine tune the proxy you use the original https://www.w3.org/TR/webdriver/#proxy[object] and pass it to capabilities: | ||
To fine tune the proxy you use the original https://www.w3.org/TR/webdriver/#proxy[object] and pass it as capabilities: | ||
|
||
//:test-doc-blocks/skip | ||
[source,clojure] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
(ns test-coverage | ||
(:require [babashka.fs :as fs] | ||
[helper.shell :as shell] | ||
[lread.status-line :as status])) | ||
|
||
(defn generate-doc-tests [] | ||
(status/line :head "Generating tests for code blocks in documents") | ||
(shell/command "clojure -X:test-doc-blocks gen-tests")) | ||
|
||
(defn run-all-tests [] | ||
(status/line :head "Running unit and code block tests under Clojure for coverage report") | ||
(shell/command "clojure" "-X:test:test-docs:clofidence")) | ||
|
||
(defn -main [& _args] | ||
(fs/delete-tree "./target/clofidence") | ||
(generate-doc-tests) | ||
(run-all-tests)) |
Oops, something went wrong.