Documentation style adjustment

FossilOrigin-Name: a5c3f281a5924eadafc14ca809ca8a8aae6fdd9ac9db1782db07d3fff697120b
This commit is contained in:
Daniel Ziltener 2023-11-09 01:21:50 +01:00
parent 68c4194793
commit 5e04cbc144
Signed by: zilti
GPG key ID: B38976E82C9DAE42
2 changed files with 77 additions and 75 deletions

View file

@ -15,7 +15,7 @@ webdriver.scm webdriver-impl.scm webdriver.html webdriver.egg webdriver.release-
-f org-html-export-to-html
mv "${.ALLSRC:[1]:R}.html" "${.ALLSRC:[1]:R}.html.old"
echo "<div class='fossil-doc' data-title='`cat "${.ALLSRC:[1]:R}.html.old" | grep 'class="title"' | sed -e 's/^.*">//' | sed -e 's/<\/h1>//'`'>" > "${.ALLSRC:[1]:R}.html"
cat "${.ALLSRC:[1]:R}.html.old" | sed -e '1,13d' | head -n -2 >> "${.ALLSRC:[1]:R}.html"
cat "${.ALLSRC:[1]:R}.html.old" | sed -e '1,11d' | head -n -2 >> "${.ALLSRC:[1]:R}.html"
echo "</div>" >> "${.ALLSRC:[1]:R}.html"
rm "${.ALLSRC:[1]:R}.html.old"

View file

@ -1,4 +1,6 @@
<div class='fossil-doc' data-title='Webdriver implementation in Chicken Scheme'>
<style>
#content { max-width: 60em; margin: auto; }
.title { text-align: center;
margin-bottom: .2em; }
.subtitle { text-align: center;
@ -189,38 +191,38 @@
<h2>Table of Contents</h2>
<div id="text-table-of-contents" role="doc-toc">
<ul>
<li><a href="#orgff39d75">1. Dependencies</a></li>
<li><a href="#org4651c2d">2. Error Conditions</a></li>
<li><a href="#org6193099">3. WebDriver</a>
<li><a href="#orgcf15ed5">1. Dependencies</a></li>
<li><a href="#org9654a3f">2. Error Conditions</a></li>
<li><a href="#org0c6a48e">3. WebDriver</a>
<ul>
<li><a href="#org4f8bad8">3.1. Geckodriver</a></li>
<li><a href="#orgf711da9">3.1. Geckodriver</a></li>
</ul>
</li>
<li><a href="#org4680eae">4. WebDriver API</a>
<li><a href="#org90a0d04">4. WebDriver API</a>
<ul>
<li><a href="#orgb60d0eb">4.1. Communication</a></li>
<li><a href="#org2a85680">4.2. Session management</a></li>
<li><a href="#org50c43d3">4.3. API Access Methods</a></li>
<li><a href="#org970cd9c">4.4. Timeouts</a>
<li><a href="#org0af98b8">4.1. Communication</a></li>
<li><a href="#orgc8415a8">4.2. Session management</a></li>
<li><a href="#orgf324492">4.3. API Access Methods</a></li>
<li><a href="#org7b9187a">4.4. Timeouts</a>
<ul>
<li><a href="#orgc089ded">4.4.1. Setting and getting timeouts</a></li>
<li><a href="#orgbd9c6f9">4.4.1. Setting and getting timeouts</a></li>
</ul>
</li>
<li><a href="#org8473447">4.5. Elements</a>
<li><a href="#orgfb95f06">4.5. Elements</a>
<ul>
<li><a href="#org870ddb2">4.5.1. Element Class</a></li>
<li><a href="#org3abcade">4.5.2. Finding Elements</a></li>
<li><a href="#org1ee7ac0">4.5.3. Working with Elements</a></li>
<li><a href="#orgb69c4d2">4.5.1. Element Class</a></li>
<li><a href="#org898fb82">4.5.2. Finding Elements</a></li>
<li><a href="#org2951da3">4.5.3. Working with Elements</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#org86b4a66">5. About This Egg</a>
<li><a href="#orgc2f2dc5">5. About This Egg</a>
<ul>
<li><a href="#orgac72f6e">5.1. Source</a></li>
<li><a href="#orgd19a870">5.2. Author</a></li>
<li><a href="#orgc04d23c">5.3. Version History</a></li>
<li><a href="#org9889d78">5.4. License</a></li>
<li><a href="#orgdd96e8f">5.1. Source</a></li>
<li><a href="#orga5a4244">5.2. Author</a></li>
<li><a href="#org10db57e">5.3. Version History</a></li>
<li><a href="#org62e841d">5.4. License</a></li>
</ul>
</li>
</ul>
@ -228,10 +230,10 @@
</div>
<div id="outline-container-orgff39d75" class="outline-2">
<h2 id="orgff39d75"><span class="section-number-2">1.</span> Dependencies</h2>
<div id="outline-container-orgcf15ed5" class="outline-2">
<h2 id="orgcf15ed5"><span class="section-number-2">1.</span> Dependencies</h2>
<div class="outline-text-2" id="text-1">
<table id="org541a8e9" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<table id="orgade00f9" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
@ -295,11 +297,11 @@
</div>
</div>
<div id="outline-container-org4651c2d" class="outline-2">
<h2 id="org4651c2d"><span class="section-number-2">2.</span> Error Conditions</h2>
<div id="outline-container-org9654a3f" class="outline-2">
<h2 id="org9654a3f"><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="orgbc037c3">(define-condition-type &amp;wd-exception &amp;error wd-exception?
<pre class="src src-scheme" id="org93a940f">(define-condition-type &amp;wd-exception &amp;error wd-exception?
(stacktrace wd-stacktrace)
(data wd-data))
</pre>
@ -309,7 +311,7 @@
Every API error code (key "error" 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="orgecaa72e" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<table id="org1401727" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
@ -468,15 +470,15 @@ Every API error code (key "error" in the returned JSON data) gets its own condit
</div>
</div>
<div id="outline-container-org6193099" class="outline-2">
<h2 id="org6193099"><span class="section-number-2">3.</span> WebDriver</h2>
<div id="outline-container-org0c6a48e" class="outline-2">
<h2 id="org0c6a48e"><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="org44a4d03">(<span style="font-weight: bold;">define-class</span> <span style="font-weight: bold; text-decoration: underline;">&lt;WebDriver&gt;</span> ()
<pre class="src src-scheme" id="orgc21fbf1">(<span style="font-weight: bold;">define-class</span> <span style="font-weight: bold; text-decoration: underline;">&lt;WebDriver&gt;</span> ()
((browser #f)
(active? #f)
(browser-pid #f)
@ -493,7 +495,7 @@ The parent class provides a handful of methods, but does not implement all of th
</p>
<div class="org-src-container">
<pre class="src src-scheme" id="orgf8c4322">(<span style="font-weight: bold;">define-method</span> (<span style="font-weight: bold;">launch</span> <span style="font-weight: bold;">#:after</span> (instance <span style="font-weight: bold; text-decoration: underline;">&lt;WebDriver&gt;</span>) options)
<pre class="src src-scheme" id="org23c2abe">(<span style="font-weight: bold;">define-method</span> (<span style="font-weight: bold;">launch</span> <span style="font-weight: bold;">#:after</span> (instance <span style="font-weight: bold; text-decoration: underline;">&lt;WebDriver&gt;</span>) options)
(set-finalizer! instance (<span style="font-weight: bold;">lambda</span> (obj)
(<span style="font-weight: bold;">when</span> (slot-value instance 'active?)
(terminate instance)))))
@ -517,7 +519,7 @@ Main initialization is done by calling the <code>new-WebDriver</code> procedure
</p>
<div class="org-src-container">
<pre class="src src-scheme" id="org6bc1a19">(<span style="font-weight: bold;">define</span> (<span style="font-weight: bold;">new-WebDriver</span> browser #!optional options)
<pre class="src src-scheme" id="org08997aa">(<span style="font-weight: bold;">define</span> (<span style="font-weight: bold;">new-WebDriver</span> browser #!optional options)
(<span style="font-weight: bold;">let</span> ((instance (make browser)))
(launch instance options)
(sleep 1)
@ -526,15 +528,15 @@ Main initialization is done by calling the <code>new-WebDriver</code> procedure
</div>
</div>
<div id="outline-container-org4f8bad8" class="outline-3">
<h3 id="org4f8bad8"><span class="section-number-3">3.1.</span> Geckodriver</h3>
<div id="outline-container-orgf711da9" class="outline-3">
<h3 id="orgf711da9"><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="orgd7e1d00">(<span style="font-weight: bold;">define-class</span> <span style="font-weight: bold; text-decoration: underline;">&lt;Gecko&gt;</span> (<span style="font-weight: bold; text-decoration: underline;">&lt;WebDriver&gt;</span>)
<pre class="src src-scheme" id="org5224a0d">(<span style="font-weight: bold;">define-class</span> <span style="font-weight: bold; text-decoration: underline;">&lt;Gecko&gt;</span> (<span style="font-weight: bold; text-decoration: underline;">&lt;WebDriver&gt;</span>)
((browser <span style="font-weight: bold;">#:firefox</span>)
(server <span style="font-style: italic;">"127.0.0.1"</span>)
(port 4444)))
@ -553,7 +555,7 @@ For more information on capabilities, see <a href="https://developer.mozilla.org
</p>
<div class="org-src-container">
<pre class="src src-scheme" id="org5a3ee36">(<span style="font-weight: bold;">define-method</span> (<span style="font-weight: bold;">construct-capabilities</span> (instance <span style="font-weight: bold; text-decoration: underline;">&lt;Gecko&gt;</span>))
<pre class="src src-scheme" id="org024c29a">(<span style="font-weight: bold;">define-method</span> (<span style="font-weight: bold;">construct-capabilities</span> (instance <span style="font-weight: bold; text-decoration: underline;">&lt;Gecko&gt;</span>))
(<span style="font-weight: bold;">let</span> ((caps (<span style="font-weight: bold;">or</span> (slot-value instance 'capabilities) (list))))
`((capabilities . ,caps))))
</pre>
@ -564,7 +566,7 @@ Sometimes, Geckodriver returns the results of a command in a JSON object with th
</p>
<div class="org-src-container">
<pre class="src src-scheme" id="org6ddb4c4">(<span style="font-weight: bold;">define-method</span> (<span style="font-weight: bold;">postprocess-result</span> (instance <span style="font-weight: bold; text-decoration: underline;">&lt;Gecko&gt;</span>) result)
<pre class="src src-scheme" id="org2cc8f63">(<span style="font-weight: bold;">define-method</span> (<span style="font-weight: bold;">postprocess-result</span> (instance <span style="font-weight: bold; text-decoration: underline;">&lt;Gecko&gt;</span>) result)
(alist-ref/default result 'value result))
</pre>
</div>
@ -572,19 +574,19 @@ Sometimes, Geckodriver returns the results of a command in a JSON object with th
</div>
</div>
<div id="outline-container-org4680eae" class="outline-2">
<h2 id="org4680eae"><span class="section-number-2">4.</span> WebDriver API</h2>
<div id="outline-container-org90a0d04" class="outline-2">
<h2 id="org90a0d04"><span class="section-number-2">4.</span> WebDriver API</h2>
<div class="outline-text-2" id="text-4">
</div>
<div id="outline-container-orgb60d0eb" class="outline-3">
<h3 id="orgb60d0eb"><span class="section-number-3">4.1.</span> Communication</h3>
<div id="outline-container-org0af98b8" class="outline-3">
<h3 id="org0af98b8"><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="org13f277a">(<span style="font-weight: bold;">define-method</span> (<span style="font-weight: bold;">send</span> (instance <span style="font-weight: bold; text-decoration: underline;">&lt;WebDriver&gt;</span>) data uri method)
<pre class="src src-scheme" id="org9aa4391">(<span style="font-weight: bold;">define-method</span> (<span style="font-weight: bold;">send</span> (instance <span style="font-weight: bold; text-decoration: underline;">&lt;WebDriver&gt;</span>) data uri method)
(<span style="font-weight: bold;">let*</span> ((remote (string-append <span style="font-style: italic;">"http://"</span> (slot-value instance 'server) <span style="font-style: italic;">":"</span> (-&gt;string (slot-value instance 'port)) <span style="font-style: italic;">"/"</span>))
(result (postprocess-result instance
(with-input-from-request
@ -604,22 +606,22 @@ Data is sent to the API via a central class method. For convenience, there is a
</div>
</div>
<div id="outline-container-org2a85680" class="outline-3">
<h3 id="org2a85680"><span class="section-number-3">4.2.</span> Session management</h3>
<div id="outline-container-orgc8415a8" class="outline-3">
<h3 id="orgc8415a8"><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="org31bcb1b">(<span style="font-weight: bold;">define-method</span> (<span style="font-weight: bold;">initialize-session</span> (instance <span style="font-weight: bold; text-decoration: underline;">&lt;WebDriver&gt;</span>))
<pre class="src src-scheme" id="orga2b91e8">(<span style="font-weight: bold;">define-method</span> (<span style="font-weight: bold;">initialize-session</span> (instance <span style="font-weight: bold; text-decoration: underline;">&lt;WebDriver&gt;</span>))
(<span style="font-weight: bold;">let</span> ((result (send instance (construct-capabilities instance) <span style="font-style: italic;">"session"</span> 'POST)))
(set! (slot-value instance 'session-id) (alist-ref result 'sessionId))))
</pre>
</div>
<div class="org-src-container">
<pre class="src src-scheme" id="orgf32e94f">(<span style="font-weight: bold;">define-method</span> (<span style="font-weight: bold;">terminate-session</span> (instance <span style="font-weight: bold; text-decoration: underline;">&lt;WebDriver&gt;</span>))
<pre class="src src-scheme" id="orged636bc">(<span style="font-weight: bold;">define-method</span> (<span style="font-weight: bold;">terminate-session</span> (instance <span style="font-weight: bold; text-decoration: underline;">&lt;WebDriver&gt;</span>))
(<span style="font-weight: bold;">when</span> (slot-value instance 'session-id)
(send instance #f (string-append <span style="font-style: italic;">"session/"</span> (slot-value instance 'session-id)) 'DELETE))
(set! (slot-value instance 'session-id) #f))
@ -638,11 +640,11 @@ Session id after termination ......................................... [ PASS]
</div>
</div>
<div id="outline-container-org50c43d3" class="outline-3">
<h3 id="org50c43d3"><span class="section-number-3">4.3.</span> API Access Methods</h3>
<div id="outline-container-orgf324492" class="outline-3">
<h3 id="orgf324492"><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="org9ff460f">(<span style="font-weight: bold;">define-method</span> (<span style="font-weight: bold;">set-url</span> (instance <span style="font-weight: bold; text-decoration: underline;">&lt;WebDriver&gt;</span>) url)
<pre class="src src-scheme" id="orgc9e0623">(<span style="font-weight: bold;">define-method</span> (<span style="font-weight: bold;">set-url</span> (instance <span style="font-weight: bold; text-decoration: underline;">&lt;WebDriver&gt;</span>) url)
(send-with-session instance `((url . ,url)) <span style="font-style: italic;">"url"</span> 'POST))
(<span style="font-weight: bold;">define-method</span> (<span style="font-weight: bold;">url</span> (instance <span style="font-weight: bold; text-decoration: underline;">&lt;WebDriver&gt;</span>))
@ -722,8 +724,8 @@ Navigating to the first website ...................................... [ PASS]
</div>
</div>
<div id="outline-container-org970cd9c" class="outline-3">
<h3 id="org970cd9c"><span class="section-number-3">4.4.</span> Timeouts</h3>
<div id="outline-container-org7b9187a" class="outline-3">
<h3 id="org7b9187a"><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:
@ -752,8 +754,8 @@ The following timeouts are defined:
</div>
</div>
<div id="outline-container-orgc089ded" class="outline-4">
<h4 id="orgc089ded"><span class="section-number-4">4.4.1.</span> Setting and getting timeouts</h4>
<div id="outline-container-orgbd9c6f9" class="outline-4">
<h4 id="orgbd9c6f9"><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="font-weight: bold;">define-method</span> (<span style="font-weight: bold;">set-timeouts</span> (instance <span style="font-weight: bold; text-decoration: underline;">&lt;WebDriver&gt;</span>) (timeouts <span style="font-weight: bold; text-decoration: underline;">&lt;WDTimeouts&gt;</span>))
@ -771,12 +773,12 @@ The following timeouts are defined:
</div>
</div>
<div id="outline-container-org8473447" class="outline-3">
<h3 id="org8473447"><span class="section-number-3">4.5.</span> Elements</h3>
<div id="outline-container-orgfb95f06" class="outline-3">
<h3 id="orgfb95f06"><span class="section-number-3">4.5.</span> Elements</h3>
<div class="outline-text-3" id="text-4-5">
</div>
<div id="outline-container-org870ddb2" class="outline-4">
<h4 id="org870ddb2"><span class="section-number-4">4.5.1.</span> Element Class</h4>
<div id="outline-container-orgb69c4d2" class="outline-4">
<h4 id="orgb69c4d2"><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="font-weight: bold;">define-class</span> <span style="font-weight: bold; text-decoration: underline;">&lt;WDElement&gt;</span> ()
@ -795,12 +797,12 @@ The following timeouts are defined:
</div>
</div>
<div id="outline-container-org3abcade" class="outline-4">
<h4 id="org3abcade"><span class="section-number-4">4.5.2.</span> Finding Elements</h4>
<div id="outline-container-org898fb82" class="outline-4">
<h4 id="org898fb82"><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="org671c47f"></a>Location Strategies<br />
<li><a id="org83c0f36"></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="font-weight: bold;">define</span> <span style="font-weight: bold;">css-selector</span> <span style="font-style: italic;">"css selector"</span>)
@ -813,7 +815,7 @@ The following timeouts are defined:
</div>
</li>
<li><a id="orgd2e56a5"></a>Accessor Methods<br />
<li><a id="org4fe962b"></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="font-weight: bold;">define-method</span> (<span style="font-weight: bold;">find-element</span> (instance <span style="font-weight: bold; text-decoration: underline;">&lt;WebDriver&gt;</span>) strategy selector)
@ -855,8 +857,8 @@ The following timeouts are defined:
</ol>
</div>
<div id="outline-container-org1ee7ac0" class="outline-4">
<h4 id="org1ee7ac0"><span class="section-number-4">4.5.3.</span> Working with Elements</h4>
<div id="outline-container-org2951da3" class="outline-4">
<h4 id="org2951da3"><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="font-weight: bold;">define-method</span> (<span style="font-weight: bold;">attribute</span> (instance <span style="font-weight: bold; text-decoration: underline;">&lt;WDElement&gt;</span>) attribute)
@ -945,12 +947,12 @@ The following timeouts are defined:
</div>
</div>
<div id="outline-container-org86b4a66" class="outline-2">
<h2 id="org86b4a66"><span class="section-number-2">5.</span> About This Egg</h2>
<div id="outline-container-orgc2f2dc5" class="outline-2">
<h2 id="orgc2f2dc5"><span class="section-number-2">5.</span> About This Egg</h2>
<div class="outline-text-2" id="text-5">
</div>
<div id="outline-container-orgac72f6e" class="outline-3">
<h3 id="orgac72f6e"><span class="section-number-3">5.1.</span> Source</h3>
<div id="outline-container-orgdd96e8f" class="outline-3">
<h3 id="orgdd96e8f"><span class="section-number-3">5.1.</span> Source</h3>
<div class="outline-text-3" id="text-5-1">
<p>
The source is available at <a href="https://fossil.lyrion.ch/chicken-webdriver">https://fossil.lyrion.ch/chicken-webdriver</a>.
@ -958,8 +960,8 @@ The source is available at <a href="https://fossil.lyrion.ch/chicken-webdriver">
</div>
</div>
<div id="outline-container-orgd19a870" class="outline-3">
<h3 id="orgd19a870"><span class="section-number-3">5.2.</span> Author</h3>
<div id="outline-container-orga5a4244" class="outline-3">
<h3 id="orga5a4244"><span class="section-number-3">5.2.</span> Author</h3>
<div class="outline-text-3" id="text-5-2">
<p>
Daniel Ziltener
@ -967,10 +969,10 @@ Daniel Ziltener
</div>
</div>
<div id="outline-container-orgc04d23c" class="outline-3">
<h3 id="orgc04d23c"><span class="section-number-3">5.3.</span> Version History</h3>
<div id="outline-container-org10db57e" class="outline-3">
<h3 id="org10db57e"><span class="section-number-3">5.3.</span> Version History</h3>
<div class="outline-text-3" id="text-5-3">
<table id="org3b5abd1" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<table id="org49cf4e2" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
@ -988,8 +990,8 @@ Daniel Ziltener
</div>
</div>
<div id="outline-container-org9889d78" class="outline-3">
<h3 id="org9889d78"><span class="section-number-3">5.4.</span> License</h3>
<div id="outline-container-org62e841d" class="outline-3">
<h3 id="org62e841d"><span class="section-number-3">5.4.</span> License</h3>
<div class="outline-text-3" id="text-5-4">
<div class="org-src-container">
<pre class="src src-fundamental">Copyright (C) 2023 Daniel Ziltener
@ -1025,7 +1027,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</div>
<div id="postamble" class="status">
<p class="author">Author: Daniel Ziltener</p>
<p class="date">Created: 2023-04-13 Do 16:54</p>
<p class="date">Created: 2023-04-13 Do 17:01</p>
<p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</div>