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

docs: user-guide: describe execute fn #459

Merged
merged 2 commits into from
Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ Fixed.
*** Checking code blocks with https://github.com/lread/test-doc-blocks[test-doc-blocks]
*** https://github.com/clj-commons/etaoin/commit/f3f0370fb76bc353c14293243410db1641f99c70[f3f0370]: A new troubleshooting tip (thanks https://github.com/jkrasnay[@jkrasnay]!)
*** https://github.com/clj-commons/etaoin/pull/364[#364]: A new usage example (thanks https://github.com/kidd[kidd]!)
*** https://github.com/clj-commons/etaoin/issues/427[#427] https://github.com/clj-commons/etaoin/issues/359[#359]: Describe `execute` function
* Internal quality
** https://github.com/clj-commons/etaoin/issues/382[#382]: Fix process fork testing on Windows
** https://github.com/clj-commons/etaoin/issues/391[#391]: Identify browser name on failed ide tests
Expand Down
31 changes: 30 additions & 1 deletion doc/01-user-guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1512,7 +1512,36 @@ this is equivalent to something along the lines of:

== Peeking deeper

Sometimes it is useful to peek a little deeper.
Sometimes it is useful to go a little deeper.

=== Invoking WebDriver Implementation Specific Features

The Etaoin API exposes an abstraction of the W3C WebDriver protocol.
This is normally all you need, but sometimes you'll want to invoke a WebDriver implementation feature that is not part of the WebDriver protocol.

Etaoin talks to the WebDriver process via its `execute` function.
You can use this lower level function to send whatever you like to the WebDriver process.

As a real-world example, Chrome supports taking screenshots with transparent backgrounds.

Here we use Etaoin's `execute` function to ask Chrome to do this:

[source,clojure]
----
(e/with-chrome driver
;; navigate to our sample page
(e/go driver sample-page)
;; send the Chrome-specific request for a transparent background
(e/execute {:driver driver
:method :post
:path [:session (:session driver) "chromium" "send_command_and_get_result"]
:data {:cmd "Emulation.setDefaultBackgroundColorOverride"
:params {:color {:r 0 :g 0 :b 0 :a 0}}}})
;; and here we take an element screenshot as per normal
(e/screenshot-element driver
{:tag :form}
(str "target/etaoin-play/saved-screenshots/form.png")))
----

=== Reading a Browser's Console Logs [[console-logs]]

Expand Down