<?xml version="1.0" encoding="utf-8"?>
<t:test xmlns:t="http://xproc.org/ns/testsuite/3.0"
        xml:base="selenium-014.xml"
        name="selenium-014.xml"
        expected="pass"
        features="selenium">
   <t:info>
      <t:title>selenium-014</t:title>
      <t:revision-history>
         <t:revision>
            <t:date>2025-05-23</t:date>
            <t:author>
               <t:name>Norm Tovey-Walsh</t:name>
            </t:author>
            <t:description xmlns="http://www.w3.org/1999/xhtml">
               <p>Added static options for web server host and port.</p>
            </t:description>
         </t:revision>
         <t:revision>
            <t:date>2025-02-09</t:date>
            <t:author>
               <t:name>Norm Tovey-Walsh</t:name>
            </t:author>
            <t:description xmlns="http://www.w3.org/1999/xhtml">
               <p>Created test.</p>
            </t:description>
         </t:revision>
      </t:revision-history>
   </t:info>
   <t:description xmlns="http://www.w3.org/1999/xhtml">
      <p>Tests that Selenium can type in an textarea then click a button.</p>
   </t:description>
   <t:pipeline>
      <p:declare-step xmlns:cx="http://xmlcalabash.com/ns/extensions"
                      xmlns:p="http://www.w3.org/ns/xproc"
                      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 &lt;em&gt;text&lt;/em&gt;.
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>
   </t:pipeline>
   <t:schematron>
      <s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron" 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>
   </t:schematron>
   <t:result name="selenium-014.xml">
      <p id="iknowwhatyoudid">You updated the text box</p>
   </t:result>
</t:test>
