Features: selenium

selenium-014

Tests that Selenium can type in an textarea then click a button.

Test is expected to pass.

The pipeline

<p:declare-step xmlns:cx="http://xmlcalabash.com/ns/extensions"
                xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:t="http://xproc.org/ns/testsuite/3.0" name="main" version="3.0">
   <p:import href="https://xmlcalabash.com/ext/library/selenium.xpl"/>
   <p:output port="result" sequence="true"/>
   <p:option name="WHOST"
             select="'http://localhost:8246'" static="true"/>
   <cx:selenium>
      <p:with-option name="arguments"
                     select="('--headless')"/>
      <p:with-input>
         <p:inline content-type="text/plain">script version 0.2 .
page "{$WHOST}/apps/forms.html" .
find $textarea by id = "text" .
find $button by id = "text-update" .
send §This is some text.
This is some more <em>text</em>.
And yet more.§ to $textarea .
click $button .
find $message by id = "iknowwhatyoudid" .
output $message to result .</p:inline>
      </p:with-input>
   </cx:selenium>
</p:declare-step>

Result

<p xmlns="http://www.w3.org/1999/xhtml"
   xmlns:t="http://xproc.org/ns/testsuite/3.0" id="iknowwhatyoudid">You updated the text box</p>

Schematron checks

<s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron"
          xmlns:t="http://xproc.org/ns/testsuite/3.0" queryBinding="xslt2">
   <s:ns prefix="h" uri="http://www.w3.org/1999/xhtml"/>
   <s:pattern>
      <s:rule context="/">
         <s:assert test="h:p">The result isn’t a p.</s:assert>
         <s:assert test="h:p = 'You updated the text box'">Wrong result.</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

23 May 2025, Norm Tovey-Walsh
Added static options for web server host and port.
09 Feb 2025, Norm Tovey-Walsh
Created test.