- From: Norm Tovey-Walsh <ndw@nwalsh.com>
- Date: Sat, 25 Jan 2025 11:23:56 +0000
- To: "xproc-dev@w3.org" <xproc-dev@w3.org>
Norm Tovey-Walsh <ndw@nwalsh.com> writes:
> If you literally wanted to drive Selenium, …
It proved to be an irresistible challenge. I managed to bang out a proof-of-concept in a couple of hours. I invented a horrible little language for describing the desired interaction, then I cooked up an iXML grammar for it, then I implemented finding elements, sending keys, clicking buttons, waiting, and grabbing content from the page.
This step:
<cx:selenium browser="firefox">
<p:with-option name="arguments" select="('--headless')"/>
<p:with-input>
<p:inline content-type="text/plain">script version 0.1 .
page "https://www.wikipedia.org/" .
element search = find-selector("#searchInput") .
element button = find-selector("button[type='submit']") .
text search "xproc" .
click button .
wait reload search .
element content = find-selector(".mw-body-content") .
grab content .
</p:inline>
</p:with-input>
</cx:selenium>
uses Selenium with the Firefox web driver to load and interact with the web. It returns the main content of the Wikipedia article about XProc. :-)
The step declaration is:
<p:declare-step type="cx:selenium">
<p:input port="source" content-types="text"/>
<p:output port="result" content-types="html" sequence="true"/>
<p:option name="browser" as="xs:string" required="true"
values="('firefox', 'chrome', 'safari', 'edge', 'internetexplorer')"/>
<p:option name="capabilities" as="map(xs:QName, item())?"/>
<p:option name="arguments" as="xs:string*"/>
</p:declare-step>
The language for describing interaction is too awful to document or release, but I’ll see if I get anywhere with it.
Be seeing you,
norm
--
Norm Tovey-Walsh <ndw@nwalsh.com>
https://norm.tovey-walsh.com/
> Knowledge comes, but wisdom lingers.--Alfred Lord Tennyson
Received on Saturday, 25 January 2025 11:24:03 UTC