diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 538419e..081dd79 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -22,8 +22,38 @@ A release with an intentional breaking changes is marked with: * Technically breaking ** {issue}613[#612]: Remove all support for long obsolete and long untested PhantomJS ({lread}) +** {issue}467[#467]: Move to W3C WebDriver spec. +({lread}) +*** The impetus was Firefox no longer supporting legacy `:capabilities` syntax. +The breaking impact was on Chrome/Edge, when in "w3c mode" it will fail on WebDriver endpoints where there is a viable w3c alternative. +This means some custom Chrome specific fns should now be expressed as w3c WebDriver actions. +The following Chrome-specific fns have been 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` +*** Remove internal support for undocumented `:desired-capabilities`. +The implementation was either ultra legacy or misunderstood legacy APIs. * Other changes +** Add new fns that more lightly abstract W3C WebDriver Spec (as part of {issue}467[#467] API review sweep) +({lread}) +*** `get-timeouts` - as alternative to `get-*-timeout` +*** `set-timeouts` - as alternative to `set-*-timeout` +*** `get-element-rect` - as alternative to `get-element-size`, `get-element-location` +*** `get-element-rect-el` - as alternative to `get-element-size-el`, `get-element-location-el` +*** `get-window-rect` - as alternative to `get-window-size`, `get-window-position` +*** `set-window-rect` - as alternative to `set-window-size`, `set-window-position` +** Review tests and add some missing coverage (as part of {issue}467[#467] API review sweep) +({lread}) +** {issue}467[#467]: Required a full sweep of the API, so also includes: +({lread}) ** {pr}552[#552]: Add support for wide characters to input fill functions ({person}tupini07[@tupini07]) ** {issue}566[#566]: Recognize `:driver-log-level` for Edge @@ -48,6 +78,8 @@ A release with an intentional breaking changes is marked with: ({lread}) *** {issue}602[#602]: Document all `:fn/*` query pseudo-functions in a definitive list ({person}dgr[@dgr]) +*** {issue}484[#484]: Add W3C WebDriver Spec links to docstrings +*** {issue}522[#522]: Via better docstrings on getting properties == v1.0.40 - 2023-03-08 [[v1.0.40]] diff --git a/bb.edn b/bb.edn index 030eb45..4f0792f 100644 --- a/bb.edn +++ b/bb.edn @@ -66,8 +66,10 @@ :task test-server/-main} test:bb {:doc "Runs tests under Babashka [--help]" :task test/test-bb} - test-doc {:doc "test code blocks in user guide" + test-doc {:doc "Test code blocks in user guide" :task test-doc/test-doc} + test-coverage {:doc "Run doc and unit tests on JVM and generate ./target/clofidence code coverage report" + :task test-coverage/-main} test-matrix {:doc "Returns a test matrix for CI [--help]" :task test-matrix/-main} drivers {:doc "[list|kill] any running WebDrivers" diff --git a/deps.edn b/deps.edn index ef9d7c2..40ee03c 100644 --- a/deps.edn +++ b/deps.edn @@ -12,7 +12,7 @@ :aliases {;; we use babashka/neil for project attributes ;; publish workflow references these values (and automatically bumps patch component of version) - :neil {:project {:version "1.0.40" ;; describes last release and is template for next release + :neil {:project {:version "1.1.40" ;; describes last release and is template for next release :name etaoin/etaoin ;; not neilisms - could potentially conflict with new neilisms :github-coords clj-commons/etaoin}} @@ -51,6 +51,16 @@ :vars [:symbol]}} :main-opts ["-m" "babashka.cli.exec"]} + :clofidence {:classpath-overrides {org.clojure/clojure nil} + :extra-deps {com.github.flow-storm/clojure {:mvn/version "LATEST"} ; >= 1.11.1-15 + com.github.flow-storm/clofidence {:mvn/version "LATEST"}} + :exec-fn clofidence.main/run + :exec-args {:report-name "Etaoin Test Coverage" + :output-folder "target/clofidence" + :test-fn cognitect.test-runner.api/test + :test-fn-args [{:dirs ["test" "target/test-doc-blocks/test"]}]} + :jvm-opts ["-Dclojure.storm.instrumentOnlyPrefixes=etaoin"]} + ;; for consistent linting we use a specific version of clj-kondo through the jvm :clj-kondo {:extra-deps {clj-kondo/clj-kondo {:mvn/version "2024.05.24"}} :main-opts ["-m" "clj-kondo.main"]} diff --git a/doc/01-user-guide.adoc b/doc/01-user-guide.adoc index ace2371..e096f9e 100644 --- a/doc/01-user-guide.adoc +++ b/doc/01-user-guide.adoc @@ -173,7 +173,7 @@ Edge and `msedgedriver` must match so you might need to specify the version: `scoop install edgedriver@101.0.1210.0` ** 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-` 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 <> [id=opt-driver-log-level,reftext=`:driver-log-level`] @@ -2473,9 +2465,9 @@ _Default:_ _Example:_ See <> 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 <> 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] diff --git a/doc/02-developer-guide.adoc b/doc/02-developer-guide.adoc index fcbeba2..4559a69 100644 --- a/doc/02-developer-guide.adoc +++ b/doc/02-developer-guide.adoc @@ -237,6 +237,20 @@ Run `bb cljdoc-preview --help` for help. * `bb cljdoc-preview view` opens a view to your imported docs in your default web browser * `bb cljdoc-preview stop` stops the docker image +=== Test Coverage +Sometimes it's nice to get an idea of what parts of Etaoin its unit and doc tests (or more importantly, don't) cover. + +[source,shell] +---- +bb test-coverage +---- + +The intent is not to strive for some percentage of coverage, just information on what is not covered. + +When possible, run from macOS, the only OS where we hit all supported browsers (you'll need all browsers and WebDrivers installed and up to date). + +It will take a while, but after tests are complete, crack open `./target/clofidence/index.html` for results. + == Other Notes === Logging diff --git a/env/test/resources/static/test.html b/env/test/resources/static/test.html index 837d1a8..43b86b4 100644 --- a/env/test/resources/static/test.html +++ b/env/test/resources/static/test.html @@ -6,16 +6,16 @@ -

Click section

+ + -
+

CSS section