Skip to content

Commit

Permalink
docs: user-guide: describe execute fn (#459)
Browse files Browse the repository at this point in the history
Closes #359, closes #427
  • Loading branch information
lread authored Jun 20, 2022
1 parent d3f06bd commit 926bf02
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
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

0 comments on commit 926bf02

Please sign in to comment.