raft/webdriver.html

957 lines
69 KiB
HTML
Raw Normal View History

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2023-04-13 Do 16:13 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Webdriver implementation in Chicken Scheme</title>
<meta name="author" content="Daniel Ziltener" />
<meta name="generator" content="Org Mode" />
<style>
#content { max-width: 60em; margin: auto; }
.title { text-align: center;
margin-bottom: .2em; }
.subtitle { text-align: center;
font-size: medium;
font-weight: bold;
margin-top:0; }
.todo { font-family: monospace; color: red; }
.done { font-family: monospace; color: green; }
.priority { font-family: monospace; color: orange; }
.tag { background-color: #eee; font-family: monospace;
padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; }
.org-right { margin-left: auto; margin-right: 0px; text-align: right; }
.org-left { margin-left: 0px; margin-right: auto; text-align: left; }
.org-center { margin-left: auto; margin-right: auto; text-align: center; }
.underline { text-decoration: underline; }
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre {
border: 1px solid #e6e6e6;
border-radius: 3px;
background-color: #f2f2f2;
padding: 8pt;
font-family: monospace;
overflow: auto;
margin: 1.2em;
}
pre.src {
position: relative;
overflow: auto;
}
pre.src:before {
display: none;
position: absolute;
top: -8px;
right: 12px;
padding: 3px;
color: #555;
background-color: #f2f2f299;
}
pre.src:hover:before { display: inline; margin-top: 14px;}
/* Languages per Org manual */
pre.src-asymptote:before { content: 'Asymptote'; }
pre.src-awk:before { content: 'Awk'; }
pre.src-authinfo::before { content: 'Authinfo'; }
pre.src-C:before { content: 'C'; }
/* pre.src-C++ doesn't work in CSS */
pre.src-clojure:before { content: 'Clojure'; }
pre.src-css:before { content: 'CSS'; }
pre.src-D:before { content: 'D'; }
pre.src-ditaa:before { content: 'ditaa'; }
pre.src-dot:before { content: 'Graphviz'; }
pre.src-calc:before { content: 'Emacs Calc'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-fortran:before { content: 'Fortran'; }
pre.src-gnuplot:before { content: 'gnuplot'; }
pre.src-haskell:before { content: 'Haskell'; }
pre.src-hledger:before { content: 'hledger'; }
pre.src-java:before { content: 'Java'; }
pre.src-js:before { content: 'Javascript'; }
pre.src-latex:before { content: 'LaTeX'; }
pre.src-ledger:before { content: 'Ledger'; }
pre.src-lisp:before { content: 'Lisp'; }
pre.src-lilypond:before { content: 'Lilypond'; }
pre.src-lua:before { content: 'Lua'; }
pre.src-matlab:before { content: 'MATLAB'; }
pre.src-mscgen:before { content: 'Mscgen'; }
pre.src-ocaml:before { content: 'Objective Caml'; }
pre.src-octave:before { content: 'Octave'; }
pre.src-org:before { content: 'Org mode'; }
pre.src-oz:before { content: 'OZ'; }
pre.src-plantuml:before { content: 'Plantuml'; }
pre.src-processing:before { content: 'Processing.js'; }
pre.src-python:before { content: 'Python'; }
pre.src-R:before { content: 'R'; }
pre.src-ruby:before { content: 'Ruby'; }
pre.src-sass:before { content: 'Sass'; }
pre.src-scheme:before { content: 'Scheme'; }
pre.src-screen:before { content: 'Gnu Screen'; }
pre.src-sed:before { content: 'Sed'; }
pre.src-sh:before { content: 'shell'; }
pre.src-sql:before { content: 'SQL'; }
pre.src-sqlite:before { content: 'SQLite'; }
/* additional languages in org.el's org-babel-load-languages alist */
pre.src-forth:before { content: 'Forth'; }
pre.src-io:before { content: 'IO'; }
pre.src-J:before { content: 'J'; }
pre.src-makefile:before { content: 'Makefile'; }
pre.src-maxima:before { content: 'Maxima'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-picolisp:before { content: 'Pico Lisp'; }
pre.src-scala:before { content: 'Scala'; }
pre.src-shell:before { content: 'Shell Script'; }
pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
/* additional language identifiers per "defun org-babel-execute"
in ob-*.el */
pre.src-cpp:before { content: 'C++'; }
pre.src-abc:before { content: 'ABC'; }
pre.src-coq:before { content: 'Coq'; }
pre.src-groovy:before { content: 'Groovy'; }
/* additional language identifiers from org-babel-shell-names in
ob-shell.el: ob-shell is the only babel language using a lambda to put
the execution function name together. */
pre.src-bash:before { content: 'bash'; }
pre.src-csh:before { content: 'csh'; }
pre.src-ash:before { content: 'ash'; }
pre.src-dash:before { content: 'dash'; }
pre.src-ksh:before { content: 'ksh'; }
pre.src-mksh:before { content: 'mksh'; }
pre.src-posh:before { content: 'posh'; }
/* Additional Emacs modes also supported by the LaTeX listings package */
pre.src-ada:before { content: 'Ada'; }
pre.src-asm:before { content: 'Assembler'; }
pre.src-caml:before { content: 'Caml'; }
pre.src-delphi:before { content: 'Delphi'; }
pre.src-html:before { content: 'HTML'; }
pre.src-idl:before { content: 'IDL'; }
pre.src-mercury:before { content: 'Mercury'; }
pre.src-metapost:before { content: 'MetaPost'; }
pre.src-modula-2:before { content: 'Modula-2'; }
pre.src-pascal:before { content: 'Pascal'; }
pre.src-ps:before { content: 'PostScript'; }
pre.src-prolog:before { content: 'Prolog'; }
pre.src-simula:before { content: 'Simula'; }
pre.src-tcl:before { content: 'tcl'; }
pre.src-tex:before { content: 'TeX'; }
pre.src-plain-tex:before { content: 'Plain TeX'; }
pre.src-verilog:before { content: 'Verilog'; }
pre.src-vhdl:before { content: 'VHDL'; }
pre.src-xml:before { content: 'XML'; }
pre.src-nxml:before { content: 'XML'; }
/* add a generic configuration mode; LaTeX export needs an additional
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
pre.src-conf:before { content: 'Configuration File'; }
table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; }
th.org-right { text-align: center; }
th.org-left { text-align: center; }
th.org-center { text-align: center; }
td.org-right { text-align: right; }
td.org-left { text-align: left; }
td.org-center { text-align: center; }
dt { font-weight: bold; }
.footpara { display: inline; }
.footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.equation-container {
display: table;
text-align: center;
width: 100%;
}
.equation {
vertical-align: middle;
}
.equation-label {
display: table-cell;
text-align: right;
vertical-align: middle;
}
.inlinetask {
padding: 10px;
border: 2px solid gray;
margin: 10px;
background: #ffffcc;
}
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; }
.linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight
{ background-color: #ffff00; color: #000000; font-weight: bold; }
.org-svg { }
</style>
</head>
<body>
<div id="content" class="content">
<h1 class="title">Webdriver implementation in Chicken Scheme</h1>
<div id="table-of-contents" role="doc-toc">
<h2>Table of Contents</h2>
<div id="text-table-of-contents" role="doc-toc">
<ul>
<li><a href="#org4399fba">1. Dependencies</a></li>
<li><a href="#org686fad8">2. Error Conditions</a></li>
<li><a href="#orgb911463">3. WebDriver</a>
<ul>
<li><a href="#org3d13a0c">3.1. Geckodriver</a></li>
</ul>
</li>
<li><a href="#orgf472d01">4. WebDriver API</a>
<ul>
<li><a href="#org5685400">4.1. Communication</a></li>
<li><a href="#orgd3b1c20">4.2. Session management</a></li>
<li><a href="#orgca687e8">4.3. API Access Methods</a></li>
<li><a href="#org8175c38">4.4. Timeouts</a>
<ul>
<li><a href="#org2be29cc">4.4.1. Setting and getting timeouts</a></li>
</ul>
</li>
<li><a href="#org0b96887">4.5. Elements</a>
<ul>
<li><a href="#org3abeb2f">4.5.1. Element Class</a></li>
<li><a href="#orgf5ba942">4.5.2. Finding Elements</a></li>
<li><a href="#org25c6507">4.5.3. Working with Elements</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div id="outline-container-org4399fba" class="outline-2">
<h2 id="org4399fba"><span class="section-number-2">1.</span> Dependencies</h2>
<div class="outline-text-2" id="text-1">
<table id="orgb55ce99" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Dependency</th>
<th scope="col" class="org-left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left">srfi-34</td>
<td class="org-left">Exception Handling</td>
</tr>
<tr>
<td class="org-left">srfi-35</td>
<td class="org-left">Exception Types</td>
</tr>
<tr>
<td class="org-left">base64</td>
<td class="org-left">decoding screenshot data</td>
</tr>
<tr>
<td class="org-left">http-client</td>
<td class="org-left">API interaction</td>
</tr>
<tr>
<td class="org-left">intarweb</td>
<td class="org-left">Supporting HTTP functionality</td>
</tr>
<tr>
<td class="org-left">uri-common</td>
<td class="org-left">Supporting HTTP functionality</td>
</tr>
<tr>
<td class="org-left">coops</td>
<td class="org-left">Object system</td>
</tr>
<tr>
<td class="org-left">alist-lib</td>
<td class="org-left">Handling alists from JSON objects</td>
</tr>
<tr>
<td class="org-left">medea</td>
<td class="org-left">JSON handling</td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="outline-container-org686fad8" class="outline-2">
<h2 id="org686fad8"><span class="section-number-2">2.</span> Error Conditions</h2>
<div class="outline-text-2" id="text-2">
<div class="org-src-container">
<pre class="src src-scheme" id="orgca58a9e"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-condition-type</span> &amp;wd-exception &amp;error wd-exception?
<span style="color: #c49619;">(</span>stacktrace wd-stacktrace<span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>data wd-data<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<p>
Every API error code (key &ldquo;error&rdquo; in the returned JSON data) gets its own condition type, prefixed by <code>&amp;</code>. They all inherit from <code>&amp;wd-exception</code>.
</p>
<table id="org1b76a29" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Name</th>
<th scope="col" class="org-left">API Error Code</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left">detached-shadow-root</td>
<td class="org-left">detached shadow root</td>
</tr>
<tr>
<td class="org-left">element-click-intercepted</td>
<td class="org-left">element click intercepted</td>
</tr>
<tr>
<td class="org-left">element-not-interactable</td>
<td class="org-left">element not interactable</td>
</tr>
<tr>
<td class="org-left">insecure-certificate</td>
<td class="org-left">insecure certificate</td>
</tr>
<tr>
<td class="org-left">invalid-argument</td>
<td class="org-left">invalid argument</td>
</tr>
<tr>
<td class="org-left">invalid-cookie-domain</td>
<td class="org-left">invalid cookie domain</td>
</tr>
<tr>
<td class="org-left">invalid-element-state</td>
<td class="org-left">invalid element state</td>
</tr>
<tr>
<td class="org-left">invalid-selector</td>
<td class="org-left">invalid selector</td>
</tr>
<tr>
<td class="org-left">invalid-session-id</td>
<td class="org-left">invalid session id</td>
</tr>
<tr>
<td class="org-left">javascript-error</td>
<td class="org-left">javascript error</td>
</tr>
<tr>
<td class="org-left">move-target-out-of-bounds</td>
<td class="org-left">move target out of bounds</td>
</tr>
<tr>
<td class="org-left">no-such-alert</td>
<td class="org-left">no such alert</td>
</tr>
<tr>
<td class="org-left">no-such-cookie</td>
<td class="org-left">no such cookie</td>
</tr>
<tr>
<td class="org-left">no-such-element</td>
<td class="org-left">no such element</td>
</tr>
<tr>
<td class="org-left">no-such-frame</td>
<td class="org-left">no such frame</td>
</tr>
<tr>
<td class="org-left">no-such-shadow-root</td>
<td class="org-left">no such shadow root</td>
</tr>
<tr>
<td class="org-left">no-such-window</td>
<td class="org-left">no such window</td>
</tr>
<tr>
<td class="org-left">script-timeout</td>
<td class="org-left">script timeout</td>
</tr>
<tr>
<td class="org-left">session-not-created</td>
<td class="org-left">session not created</td>
</tr>
<tr>
<td class="org-left">stale-element-reference</td>
<td class="org-left">stale element reference</td>
</tr>
<tr>
<td class="org-left">timeout</td>
<td class="org-left">timeout</td>
</tr>
<tr>
<td class="org-left">unable-to-capture-screen</td>
<td class="org-left">unable to capture screen</td>
</tr>
<tr>
<td class="org-left">unable-to-set-cookie</td>
<td class="org-left">unable to set cookie</td>
</tr>
<tr>
<td class="org-left">unexpected-alert-open</td>
<td class="org-left">unexpected alert open</td>
</tr>
<tr>
<td class="org-left">unknown-command</td>
<td class="org-left">unknown command</td>
</tr>
<tr>
<td class="org-left">unknown-error</td>
<td class="org-left">unknown error</td>
</tr>
<tr>
<td class="org-left">unknown-method</td>
<td class="org-left">unknown method</td>
</tr>
<tr>
<td class="org-left">unsupported-operation</td>
<td class="org-left">unsupported operation</td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="outline-container-orgb911463" class="outline-2">
<h2 id="orgb911463"><span class="section-number-2">3.</span> WebDriver</h2>
<div class="outline-text-2" id="text-3">
<p>
The core element of the library is the <code>&lt;WebDriver&gt;</code> class and its subclasses. The class has the following fields:
</p>
<div class="org-src-container">
<pre class="src src-scheme" id="orgdcaa051"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-class</span> <span style="color: #c49619; font-style: italic;">&lt;WebDriver&gt;</span> <span style="color: #c49619;">()</span>
<span style="color: #c49619;">(</span><span style="color: #db5823;">(</span>browser #f<span style="color: #db5823;">)</span>
<span style="color: #db5823;">(</span>active? #f<span style="color: #db5823;">)</span>
<span style="color: #db5823;">(</span>browser-pid #f<span style="color: #db5823;">)</span>
<span style="color: #db5823;">(</span>server #f<span style="color: #db5823;">)</span>
<span style="color: #db5823;">(</span>port #f<span style="color: #db5823;">)</span>
<span style="color: #db5823;">(</span>session-id #f<span style="color: #db5823;">)</span>
<span style="color: #db5823;">(</span>prefs #f<span style="color: #db5823;">)</span>
<span style="color: #db5823;">(</span>capabilities #f<span style="color: #db5823;">)</span><span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<p>
The parent class provides a handful of methods, but does not implement all of them; some are the sole responsibility of the subclass. The <code>launch</code> method, on the other hand, bears shared responsibility. It sets a finalizer to ensure termination of the web driver process in case the class is disposed of with a still-open driver.
</p>
<div class="org-src-container">
<pre class="src src-scheme" id="org47d44ea"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">launch</span> <span style="color: #3c98e0; font-style: italic;">#:after</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WebDriver&gt;</span><span style="color: #db5823;">)</span> options<span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>set-finalizer! instance <span style="color: #db5823;">(</span><span style="color: #93a61a; font-weight: bold;">lambda</span> <span style="color: #93a61a;">(</span>obj<span style="color: #93a61a;">)</span>
<span style="color: #93a61a;">(</span><span style="color: #93a61a; font-weight: bold;">when</span> <span style="color: #3c98e0;">(</span>slot-value instance 'active?<span style="color: #3c98e0;">)</span>
<span style="color: #3c98e0;">(</span>terminate instance<span style="color: #3c98e0;">)</span><span style="color: #93a61a;">)</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
<span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">terminate</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WebDriver&gt;</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>terminate-session instance<span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>process-signal <span style="color: #db5823;">(</span>slot-value instance 'browser-pid<span style="color: #db5823;">)</span><span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span><span style="color: #93a61a; font-weight: bold;">set!</span> <span style="color: #db5823;">(</span>slot-value instance 'browser-pid<span style="color: #db5823;">)</span> #f<span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span><span style="color: #93a61a; font-weight: bold;">set!</span> <span style="color: #db5823;">(</span>slot-value instance 'active?<span style="color: #db5823;">)</span> #f<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
<span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">construct-capabilities</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WebDriver&gt;</span><span style="color: #db5823;">)</span> #!optional caps<span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>raise 'subclass-responsibility<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
<span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">postprocess-result</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WebDriver&gt;</span><span style="color: #db5823;">)</span> result<span style="color: #c49619;">)</span>
result<span style="color: #3c98e0;">)</span>
</pre>
</div>
<p>
Main initialization is done by calling the <code>new-WebDriver</code> procedure with the respective class name and optionally an alist of options.
</p>
<div class="org-src-container">
<pre class="src src-scheme" id="org5798eb1"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">new-WebDriver</span> browser #!optional options<span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span><span style="color: #93a61a; font-weight: bold;">let</span> <span style="color: #db5823;">(</span><span style="color: #93a61a;">(</span>instance <span style="color: #3c98e0;">(</span>make browser<span style="color: #3c98e0;">)</span><span style="color: #93a61a;">)</span><span style="color: #db5823;">)</span>
<span style="color: #db5823;">(</span>launch instance options<span style="color: #db5823;">)</span>
<span style="color: #db5823;">(</span>sleep <span style="color: #7a7ed2; font-weight: bold;">1</span><span style="color: #db5823;">)</span>
instance<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
</div>
<div id="outline-container-org3d13a0c" class="outline-3">
<h3 id="org3d13a0c"><span class="section-number-3">3.1.</span> Geckodriver</h3>
<div class="outline-text-3" id="text-3-1">
<p>
The Geckodriver is used to control Firefox.
</p>
<div class="org-src-container">
<pre class="src src-scheme" id="orge7a717b"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-class</span> <span style="color: #c49619; font-style: italic;">&lt;Gecko&gt;</span> <span style="color: #c49619;">(</span><span style="color: #c49619; font-style: italic;">&lt;WebDriver&gt;</span><span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span><span style="color: #db5823;">(</span>browser <span style="color: #3c98e0; font-style: italic;">#:firefox</span><span style="color: #db5823;">)</span>
<span style="color: #db5823;">(</span>server <span style="color: #93a61a;">"127.0.0.1"</span><span style="color: #db5823;">)</span>
<span style="color: #db5823;">(</span>port <span style="color: #7a7ed2; font-weight: bold;">4444</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
<span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">launch</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;Gecko&gt;</span><span style="color: #db5823;">)</span> options<span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span><span style="color: #93a61a; font-weight: bold;">let</span> <span style="color: #db5823;">(</span><span style="color: #93a61a;">(</span>pid <span style="color: #3c98e0;">(</span>process-run <span style="color: #93a61a;">"geckodriver &gt; /dev/null 2&gt;&amp;1"</span><span style="color: #3c98e0;">)</span><span style="color: #93a61a;">)</span><span style="color: #db5823;">)</span>
<span style="color: #db5823;">(</span><span style="color: #93a61a; font-weight: bold;">set!</span> <span style="color: #93a61a;">(</span>slot-value instance 'browser-pid<span style="color: #93a61a;">)</span> pid<span style="color: #db5823;">)</span>
<span style="color: #db5823;">(</span><span style="color: #93a61a; font-weight: bold;">set!</span> <span style="color: #93a61a;">(</span>slot-value instance 'active?<span style="color: #93a61a;">)</span> #t<span style="color: #db5823;">)</span>
<span style="color: #db5823;">(</span><span style="color: #93a61a; font-weight: bold;">set!</span> <span style="color: #93a61a;">(</span>slot-value instance 'capabilities<span style="color: #93a61a;">)</span> options<span style="color: #db5823;">)</span><span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<p>
The capabilities object for Geckodriver is of the form <code>{"capabilities": {...}}</code>.
For more information on capabilities, see <a href="https://developer.mozilla.org/en-US/docs/Web/WebDriver/Capabilities">https://developer.mozilla.org/en-US/docs/Web/WebDriver/Capabilities</a>.
</p>
<div class="org-src-container">
<pre class="src src-scheme" id="org3337880"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">construct-capabilities</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;Gecko&gt;</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span><span style="color: #93a61a; font-weight: bold;">let</span> <span style="color: #db5823;">(</span><span style="color: #93a61a;">(</span>caps <span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">or</span> <span style="color: #c49619;">(</span>slot-value instance 'capabilities<span style="color: #c49619;">)</span> <span style="color: #c49619;">(</span>list<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span><span style="color: #93a61a;">)</span><span style="color: #db5823;">)</span>
`<span style="color: #db5823;">(</span><span style="color: #93a61a;">(</span>capabilities . ,caps<span style="color: #93a61a;">)</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<p>
Sometimes, Geckodriver returns the results of a command in a JSON object with the sole key <code>"value"</code>. We have to correct that before returning the data to the user.
</p>
<div class="org-src-container">
<pre class="src src-scheme" id="org75d89a5"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">postprocess-result</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;Gecko&gt;</span><span style="color: #db5823;">)</span> result<span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>alist-ref/default result 'value result<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-orgf472d01" class="outline-2">
<h2 id="orgf472d01"><span class="section-number-2">4.</span> WebDriver API</h2>
<div class="outline-text-2" id="text-4">
</div>
<div id="outline-container-org5685400" class="outline-3">
<h3 id="org5685400"><span class="section-number-3">4.1.</span> Communication</h3>
<div class="outline-text-3" id="text-4-1">
<p>
Data is sent to the API via a central class method. For convenience, there is a <code>send-with-session</code> variant that automatically adds the session id.
</p>
<div class="org-src-container">
<pre class="src src-scheme" id="orgaf961e8"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">send</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WebDriver&gt;</span><span style="color: #db5823;">)</span> data uri method<span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span><span style="color: #93a61a; font-weight: bold;">let*</span> <span style="color: #db5823;">(</span><span style="color: #93a61a;">(</span>remote <span style="color: #3c98e0;">(</span>string-append <span style="color: #93a61a;">"http://"</span> <span style="color: #c49619;">(</span>slot-value instance 'server<span style="color: #c49619;">)</span> <span style="color: #93a61a;">":"</span> <span style="color: #c49619;">(</span>-&gt;string <span style="color: #db5823;">(</span>slot-value instance 'port<span style="color: #db5823;">)</span><span style="color: #c49619;">)</span> <span style="color: #93a61a;">"/"</span><span style="color: #3c98e0;">)</span><span style="color: #93a61a;">)</span>
<span style="color: #93a61a;">(</span>result <span style="color: #3c98e0;">(</span>postprocess-result instance
<span style="color: #c49619;">(</span>with-input-from-request
<span style="color: #db5823;">(</span>make-request <span style="color: #3c98e0; font-style: italic;">#:method</span> method
<span style="color: #3c98e0; font-style: italic;">#:uri</span> <span style="color: #93a61a;">(</span>uri-reference <span style="color: #3c98e0;">(</span>string-append remote uri<span style="color: #3c98e0;">)</span><span style="color: #93a61a;">)</span>
<span style="color: #3c98e0; font-style: italic;">#:headers</span> <span style="color: #93a61a;">(</span>headers `<span style="color: #3c98e0;">(</span><span style="color: #c49619;">(</span>content-type application/json<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span><span style="color: #93a61a;">)</span><span style="color: #db5823;">)</span>
<span style="color: #db5823;">(</span><span style="color: #93a61a; font-weight: bold;">if</span> data <span style="color: #93a61a;">(</span>json-&gt;string data<span style="color: #93a61a;">)</span> <span style="color: #93a61a;">""</span><span style="color: #db5823;">)</span>
read-json<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span><span style="color: #93a61a;">)</span><span style="color: #db5823;">)</span>
<span style="color: #db5823;">(</span><span style="color: #93a61a; font-weight: bold;">if</span> <span style="color: #93a61a;">(</span><span style="color: #93a61a; font-weight: bold;">and</span> <span style="color: #3c98e0;">(</span>list? result<span style="color: #3c98e0;">)</span> <span style="color: #3c98e0;">(</span>alist-ref/default result 'error #f<span style="color: #3c98e0;">)</span><span style="color: #93a61a;">)</span>
<span style="color: #93a61a;">(</span>wd-throw result<span style="color: #93a61a;">)</span>
result<span style="color: #db5823;">)</span><span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
<span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">send-with-session</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WebDriver&gt;</span><span style="color: #db5823;">)</span> data uri method<span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>send instance data <span style="color: #db5823;">(</span>string-append <span style="color: #93a61a;">"session/"</span> <span style="color: #93a61a;">(</span>slot-value instance 'session-id<span style="color: #93a61a;">)</span> <span style="color: #93a61a;">"/"</span> uri<span style="color: #db5823;">)</span> method<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-orgd3b1c20" class="outline-3">
<h3 id="orgd3b1c20"><span class="section-number-3">4.2.</span> Session management</h3>
<div class="outline-text-3" id="text-4-2">
<p>
Session management is very simple. There is just one method to initialize a new session. Everything else is handled automatically.
</p>
<div class="org-src-container">
<pre class="src src-scheme" id="org9cfce71"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">initialize-session</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WebDriver&gt;</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span><span style="color: #93a61a; font-weight: bold;">let</span> <span style="color: #db5823;">(</span><span style="color: #93a61a;">(</span>result <span style="color: #3c98e0;">(</span>send instance <span style="color: #c49619;">(</span>construct-capabilities instance<span style="color: #c49619;">)</span> <span style="color: #93a61a;">"session"</span> 'POST<span style="color: #3c98e0;">)</span><span style="color: #93a61a;">)</span><span style="color: #db5823;">)</span>
<span style="color: #db5823;">(</span><span style="color: #93a61a; font-weight: bold;">set!</span> <span style="color: #93a61a;">(</span>slot-value instance 'session-id<span style="color: #93a61a;">)</span> <span style="color: #93a61a;">(</span>alist-ref result 'sessionId<span style="color: #93a61a;">)</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-scheme" id="org73e6879"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">terminate-session</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WebDriver&gt;</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span><span style="color: #93a61a; font-weight: bold;">when</span> <span style="color: #db5823;">(</span>slot-value instance 'session-id<span style="color: #db5823;">)</span>
<span style="color: #db5823;">(</span>send instance #f <span style="color: #93a61a;">(</span>string-append <span style="color: #93a61a;">"session/"</span> <span style="color: #3c98e0;">(</span>slot-value instance 'session-id<span style="color: #3c98e0;">)</span><span style="color: #93a61a;">)</span> 'DELETE<span style="color: #db5823;">)</span><span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span><span style="color: #93a61a; font-weight: bold;">set!</span> <span style="color: #db5823;">(</span>slot-value instance 'session-id<span style="color: #db5823;">)</span> #f<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<pre class="example">
-- testing session -----------------------------------------------------------
Initial state ........................................................ [ PASS]
Session id check ..................................................... [ PASS]
Session id after termination ......................................... [ PASS]
3 tests completed in 4.952 seconds.
3 out of 3 (100%) tests passed.
-- done testing session ------------------------------------------------------
</pre>
</div>
</div>
<div id="outline-container-orgca687e8" class="outline-3">
<h3 id="orgca687e8"><span class="section-number-3">4.3.</span> API Access Methods</h3>
<div class="outline-text-3" id="text-4-3">
<div class="org-src-container">
<pre class="src src-scheme" id="org9ede152"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">set-url</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WebDriver&gt;</span><span style="color: #db5823;">)</span> url<span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>send-with-session instance `<span style="color: #db5823;">(</span><span style="color: #93a61a;">(</span>url . ,url<span style="color: #93a61a;">)</span><span style="color: #db5823;">)</span> <span style="color: #93a61a;">"url"</span> 'POST<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
<span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">url</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WebDriver&gt;</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>send-with-session instance #f <span style="color: #93a61a;">"url"</span> 'GET<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<pre class="example">
-- testing url ---------------------------------------------------------------
Initial state ........................................................ [ PASS]
Navigating to the first website ...................................... [ PASS]
2 tests completed in 5.471 seconds.
2 out of 2 (100%) tests passed.
-- done testing url ----------------------------------------------------------
</pre>
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">back</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WebDriver&gt;</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>send-with-session instance #f <span style="color: #93a61a;">"back"</span> 'POST<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">forward</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WebDriver&gt;</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>send-with-session instance #f <span style="color: #93a61a;">"forward"</span> 'POST<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">forward</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WebDriver&gt;</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>send-with-session instance #f <span style="color: #93a61a;">"refresh"</span> 'POST<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">title</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WebDriver&gt;</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>send-with-session instance #f <span style="color: #93a61a;">"title"</span> 'GET<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">status</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WebDriver&gt;</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>send-with-session instance #f <span style="color: #93a61a;">"status"</span> 'GET<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">source</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WebDriver&gt;</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>send-with-session instance #f <span style="color: #93a61a;">"source"</span> 'GET<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">screenshot</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WebDriver&gt;</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>base64-decode <span style="color: #db5823;">(</span>send-with-session instance #f <span style="color: #93a61a;">"screenshot"</span> 'GET<span style="color: #db5823;">)</span><span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">print-page</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WebDriver&gt;</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>send-with-session instance #f <span style="color: #93a61a;">"print"</span> 'POST<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">execute-async</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WebDriver&gt;</span><span style="color: #db5823;">)</span> script args<span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>send-with-session instance `<span style="color: #db5823;">(</span><span style="color: #93a61a;">(</span>script . ,script<span style="color: #93a61a;">)</span> <span style="color: #93a61a;">(</span>args . ,args<span style="color: #93a61a;">)</span><span style="color: #db5823;">)</span> <span style="color: #93a61a;">"execute/async"</span> 'POST<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">execute-sync</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WebDriver&gt;</span><span style="color: #db5823;">)</span> script args<span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>send-with-session instance `<span style="color: #db5823;">(</span><span style="color: #93a61a;">(</span>script . ,script<span style="color: #93a61a;">)</span> <span style="color: #93a61a;">(</span>args . ,args<span style="color: #93a61a;">)</span><span style="color: #db5823;">)</span> <span style="color: #93a61a;">"execute/sync"</span> 'POST<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org8175c38" class="outline-3">
<h3 id="org8175c38"><span class="section-number-3">4.4.</span> Timeouts</h3>
<div class="outline-text-3" id="text-4-4">
<p>
The following timeouts are defined:
</p>
<ul class="org-ul">
<li><code>script</code>: defaults to 30&rsquo;000, specifies when to interrupt a script that is being evaluated. A nil value implies that scripts should never be interrupted, but instead run indefinitely.</li>
<li><code>pageLoad</code>: defaults to 300&rsquo;000, provides the timeout limit used to interrupt an explicit navigation attempt.</li>
<li><code>implicit</code>: defaults to 0, specifies a time to wait for the element location strategy to complete when locating an element.</li>
</ul>
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-class</span> <span style="color: #c49619; font-style: italic;">&lt;WDTimeouts&gt;</span> <span style="color: #c49619;">()</span>
<span style="color: #c49619;">(</span><span style="color: #db5823;">(</span>script <span style="color: #7a7ed2; font-weight: bold;">30000</span><span style="color: #db5823;">)</span>
<span style="color: #db5823;">(</span>pageLoad <span style="color: #7a7ed2; font-weight: bold;">300000</span><span style="color: #db5823;">)</span>
<span style="color: #db5823;">(</span>implicit <span style="color: #7a7ed2; font-weight: bold;">0</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">extract</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WDTimeouts&gt;</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span>
`<span style="color: #c49619;">(</span><span style="color: #db5823;">(</span>script . ,<span style="color: #93a61a;">(</span>slot-value instance 'script<span style="color: #93a61a;">)</span><span style="color: #db5823;">)</span>
<span style="color: #db5823;">(</span>pageLoad . ,<span style="color: #93a61a;">(</span>slot-value instance 'pageLoad<span style="color: #93a61a;">)</span><span style="color: #db5823;">)</span>
<span style="color: #db5823;">(</span>implicit . ,<span style="color: #93a61a;">(</span>slot-value instance 'implicit<span style="color: #93a61a;">)</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
</div>
<div id="outline-container-org2be29cc" class="outline-4">
<h4 id="org2be29cc"><span class="section-number-4">4.4.1.</span> Setting and getting timeouts</h4>
<div class="outline-text-4" id="text-4-4-1">
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">set-timeouts</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WebDriver&gt;</span><span style="color: #db5823;">)</span> <span style="color: #db5823;">(</span>timeouts <span style="color: #c49619; font-style: italic;">&lt;WDTimeouts&gt;</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>send-with-session instance <span style="color: #db5823;">(</span>extract timeouts<span style="color: #db5823;">)</span> <span style="color: #93a61a;">"timeouts"</span> 'POST<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
<span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">timeouts</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WebDriver&gt;</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span><span style="color: #93a61a; font-weight: bold;">let</span> <span style="color: #db5823;">(</span><span style="color: #93a61a;">(</span>result <span style="color: #3c98e0;">(</span>send-with-session instance #f <span style="color: #93a61a;">"timeouts"</span> 'GET<span style="color: #3c98e0;">)</span><span style="color: #93a61a;">)</span><span style="color: #db5823;">)</span>
<span style="color: #db5823;">(</span>make <span style="color: #c49619; font-style: italic;">&lt;WDTimeouts&gt;</span>
'script <span style="color: #93a61a;">(</span>alist-ref result 'script<span style="color: #93a61a;">)</span>
'pageLoad <span style="color: #93a61a;">(</span>alist-ref result 'pageLoad<span style="color: #93a61a;">)</span>
'implicit <span style="color: #93a61a;">(</span>alist-ref result 'implicit<span style="color: #93a61a;">)</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-org0b96887" class="outline-3">
<h3 id="org0b96887"><span class="section-number-3">4.5.</span> Elements</h3>
<div class="outline-text-3" id="text-4-5">
</div>
<div id="outline-container-org3abeb2f" class="outline-4">
<h4 id="org3abeb2f"><span class="section-number-4">4.5.1.</span> Element Class</h4>
<div class="outline-text-4" id="text-4-5-1">
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-class</span> <span style="color: #c49619; font-style: italic;">&lt;WDElement&gt;</span> <span style="color: #c49619;">()</span>
<span style="color: #c49619;">(</span><span style="color: #db5823;">(</span>driver #f<span style="color: #db5823;">)</span>
<span style="color: #db5823;">(</span>element #f<span style="color: #db5823;">)</span><span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">send-with-session</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WDElement&gt;</span><span style="color: #db5823;">)</span> data uri method<span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>send-with-session <span style="color: #db5823;">(</span>slot-value instance 'driver<span style="color: #db5823;">)</span> data
<span style="color: #db5823;">(</span>string-append <span style="color: #93a61a;">"element/"</span> <span style="color: #93a61a;">(</span>slot-value instance 'element<span style="color: #93a61a;">)</span> <span style="color: #93a61a;">"/"</span> uri<span style="color: #db5823;">)</span>
method<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-orgf5ba942" class="outline-4">
<h4 id="orgf5ba942"><span class="section-number-4">4.5.2.</span> Finding Elements</h4>
<div class="outline-text-4" id="text-4-5-2">
</div>
<ol class="org-ol">
<li><a id="org4cf0712"></a>Location Strategies<br />
<div class="outline-text-5" id="text-4-5-2-1">
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define</span> <span style="color: #3c98e0;">css-selector</span> <span style="color: #93a61a;">"css selector"</span><span style="color: #3c98e0;">)</span>
<span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define</span> <span style="color: #3c98e0;">link-text</span> <span style="color: #93a61a;">"link text"</span><span style="color: #3c98e0;">)</span>
<span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define</span> <span style="color: #3c98e0;">partial-link-text</span> <span style="color: #93a61a;">"partial link text"</span><span style="color: #3c98e0;">)</span>
<span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define</span> <span style="color: #3c98e0;">tag-name</span> <span style="color: #93a61a;">"tag name"</span><span style="color: #3c98e0;">)</span>
<span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define</span> <span style="color: #3c98e0;">xpath</span> <span style="color: #93a61a;">"xpath"</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
</div>
</li>
<li><a id="orga7a21a2"></a>Accessor Methods<br />
<div class="outline-text-5" id="text-4-5-2-2">
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">find-element</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WebDriver&gt;</span><span style="color: #db5823;">)</span> strategy selector<span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span><span style="color: #93a61a; font-weight: bold;">let</span> <span style="color: #db5823;">(</span><span style="color: #93a61a;">(</span>result <span style="color: #3c98e0;">(</span>send-with-session instance `<span style="color: #c49619;">(</span><span style="color: #db5823;">(</span>using . ,strategy<span style="color: #db5823;">)</span> <span style="color: #db5823;">(</span>value . ,selector<span style="color: #db5823;">)</span><span style="color: #c49619;">)</span> <span style="color: #93a61a;">"element"</span> 'POST<span style="color: #3c98e0;">)</span><span style="color: #93a61a;">)</span><span style="color: #db5823;">)</span>
<span style="color: #db5823;">(</span>make <span style="color: #c49619; font-style: italic;">&lt;WDElement&gt;</span> 'driver instance 'element <span style="color: #93a61a;">(</span>car <span style="color: #3c98e0;">(</span>alist-values result<span style="color: #3c98e0;">)</span><span style="color: #93a61a;">)</span><span style="color: #db5823;">)</span>
element<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">find-elements</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WebDriver&gt;</span><span style="color: #db5823;">)</span> strategy selector<span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span><span style="color: #93a61a; font-weight: bold;">let</span> <span style="color: #db5823;">(</span><span style="color: #93a61a;">(</span>result <span style="color: #3c98e0;">(</span>send-with-session instance `<span style="color: #c49619;">(</span><span style="color: #db5823;">(</span>using . ,strategy<span style="color: #db5823;">)</span> <span style="color: #db5823;">(</span>value . ,selector<span style="color: #db5823;">)</span><span style="color: #c49619;">)</span> <span style="color: #93a61a;">"elements"</span> 'POST<span style="color: #3c98e0;">)</span><span style="color: #93a61a;">)</span><span style="color: #db5823;">)</span>
<span style="color: #db5823;">(</span><span style="color: #93a61a; font-weight: bold;">map</span>
<span style="color: #93a61a;">(</span><span style="color: #93a61a; font-weight: bold;">lambda</span> <span style="color: #3c98e0;">(</span>elem<span style="color: #3c98e0;">)</span>
<span style="color: #3c98e0;">(</span>make <span style="color: #c49619; font-style: italic;">&lt;WDElement&gt;</span> 'driver instance 'element <span style="color: #c49619;">(</span>car <span style="color: #db5823;">(</span>alist-values elem<span style="color: #db5823;">)</span><span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span><span style="color: #93a61a;">)</span>
result<span style="color: #db5823;">)</span><span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">find-element</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WDElement&gt;</span><span style="color: #db5823;">)</span> strategy selector<span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span><span style="color: #93a61a; font-weight: bold;">let</span> <span style="color: #db5823;">(</span><span style="color: #93a61a;">(</span>result <span style="color: #3c98e0;">(</span>send-with-session instance `<span style="color: #c49619;">(</span><span style="color: #db5823;">(</span>using . ,strategy<span style="color: #db5823;">)</span> <span style="color: #db5823;">(</span>value . ,selector<span style="color: #db5823;">)</span><span style="color: #c49619;">)</span> <span style="color: #93a61a;">"element"</span> 'POST<span style="color: #3c98e0;">)</span><span style="color: #93a61a;">)</span><span style="color: #db5823;">)</span>
<span style="color: #db5823;">(</span>make <span style="color: #c49619; font-style: italic;">&lt;WDElement&gt;</span> 'driver <span style="color: #93a61a;">(</span>slot-value instance 'driver<span style="color: #93a61a;">)</span> 'element <span style="color: #93a61a;">(</span>car <span style="color: #3c98e0;">(</span>alist-values result<span style="color: #3c98e0;">)</span><span style="color: #93a61a;">)</span><span style="color: #db5823;">)</span>
element<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">find-elements</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WDElement&gt;</span><span style="color: #db5823;">)</span> strategy selector<span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span><span style="color: #93a61a; font-weight: bold;">let</span> <span style="color: #db5823;">(</span><span style="color: #93a61a;">(</span>result <span style="color: #3c98e0;">(</span>send-with-session instance `<span style="color: #c49619;">(</span><span style="color: #db5823;">(</span>using . ,strategy<span style="color: #db5823;">)</span> <span style="color: #db5823;">(</span>value . ,selector<span style="color: #db5823;">)</span><span style="color: #c49619;">)</span> <span style="color: #93a61a;">"elements"</span> 'POST<span style="color: #3c98e0;">)</span><span style="color: #93a61a;">)</span><span style="color: #db5823;">)</span>
<span style="color: #db5823;">(</span><span style="color: #93a61a; font-weight: bold;">map</span>
<span style="color: #93a61a;">(</span><span style="color: #93a61a; font-weight: bold;">lambda</span> <span style="color: #3c98e0;">(</span>elem<span style="color: #3c98e0;">)</span>
<span style="color: #3c98e0;">(</span>make <span style="color: #c49619; font-style: italic;">&lt;WDElement&gt;</span> 'driver <span style="color: #c49619;">(</span>slot-value instance 'driver<span style="color: #c49619;">)</span> 'element <span style="color: #c49619;">(</span>car <span style="color: #db5823;">(</span>alist-values elem<span style="color: #db5823;">)</span><span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span><span style="color: #93a61a;">)</span>
result<span style="color: #db5823;">)</span><span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
</div>
</li>
</ol>
</div>
<div id="outline-container-org25c6507" class="outline-4">
<h4 id="org25c6507"><span class="section-number-4">4.5.3.</span> Working with Elements</h4>
<div class="outline-text-4" id="text-4-5-3">
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">attribute</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WDElement&gt;</span><span style="color: #db5823;">)</span> attribute<span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span><span style="color: #93a61a; font-weight: bold;">let</span> <span style="color: #db5823;">(</span><span style="color: #93a61a;">(</span>result <span style="color: #3c98e0;">(</span>send-with-session instance #f
<span style="color: #c49619;">(</span>string-append <span style="color: #93a61a;">"attribute/"</span> attribute<span style="color: #c49619;">)</span>
'GET<span style="color: #3c98e0;">)</span><span style="color: #93a61a;">)</span><span style="color: #db5823;">)</span>
<span style="color: #db5823;">(</span><span style="color: #93a61a; font-weight: bold;">if</span> <span style="color: #93a61a;">(</span>equal? <span style="color: #93a61a;">"true"</span> result<span style="color: #93a61a;">)</span>
#t
result<span style="color: #db5823;">)</span><span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">property</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WDElement&gt;</span><span style="color: #db5823;">)</span> property<span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>send-with-session instance #f <span style="color: #db5823;">(</span>string-append <span style="color: #93a61a;">"property/"</span> property<span style="color: #db5823;">)</span> 'GET<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">clear</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WDElement&gt;</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>send-with-session instance #f <span style="color: #93a61a;">"clear"</span> 'POST<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">click</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WDElement&gt;</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>send-with-session instance #f <span style="color: #93a61a;">"click"</span> 'POST<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">computed-label</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WDElement&gt;</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>send-with-session instance #f <span style="color: #93a61a;">"computedlabel"</span> 'GET<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">computed-role</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WDElement&gt;</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>send-with-session instance #f <span style="color: #93a61a;">"computedrole"</span> 'GET<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">enabled?</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WDElement&gt;</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>send-with-session instance #f <span style="color: #93a61a;">"enabled"</span> 'GET<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">selected?</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WDElement&gt;</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>send-with-session instance #f <span style="color: #93a61a;">"selected"</span> 'GET<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">name</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WDElement&gt;</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>send-with-session instance #f <span style="color: #93a61a;">"name"</span> 'GET<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">rect</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WDElement&gt;</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>send-with-session instance #f <span style="color: #93a61a;">"rect"</span> 'GET<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">screenshot</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WDElement&gt;</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>base64-decode <span style="color: #db5823;">(</span>send-with-session instance #f <span style="color: #93a61a;">"screenshot"</span> 'GET<span style="color: #db5823;">)</span><span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">text</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WDElement&gt;</span><span style="color: #db5823;">)</span><span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>send-with-session instance #f <span style="color: #93a61a;">"text"</span> 'GET<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-scheme"><span style="color: #3c98e0;">(</span><span style="color: #93a61a; font-weight: bold;">define-method</span> <span style="color: #c49619;">(</span><span style="color: #3c98e0;">set-value</span> <span style="color: #db5823;">(</span>instance <span style="color: #c49619; font-style: italic;">&lt;WDElement&gt;</span><span style="color: #db5823;">)</span> value<span style="color: #c49619;">)</span>
<span style="color: #c49619;">(</span>send-with-session instance `<span style="color: #db5823;">(</span><span style="color: #93a61a;">(</span>text . ,value<span style="color: #93a61a;">)</span><span style="color: #db5823;">)</span> <span style="color: #93a61a;">"value"</span> 'POST<span style="color: #c49619;">)</span><span style="color: #3c98e0;">)</span>
</pre>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="postamble" class="status">
<p class="author">Author: Daniel Ziltener</p>
<p class="date">Created: 2023-04-13 Do 16:13</p>
</div>
</body>
</html>