Features: selenium

selenium-027

Tests that key up and key down work for ordinary characters.

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/keys.html" .

find $text by id = "keys" .
move to $text .

key down "c" .
find $message by id = "message" .
output $message to result .

key up "c" .
find $message by id = "message" .
output $message to result .

key down "abc" .
find $message by id = "message" .
output $message to result .

key up "b" .
find $message by id = "message" .
output $message to result .

key up "ac" .
find $message by id = "message" .
output $message to result .
          </p:inline>
      </p:with-input>
   </cx:selenium>
   <p:wrap-sequence wrapper="Q{{http://www.w3.org/1999/xhtml}}div"/>
</p:declare-step>

Result

<div xmlns="http://www.w3.org/1999/xhtml"
     xmlns:t="http://xproc.org/ns/testsuite/3.0">
   <p id="message">↓ c</p>
   <p id="message">↑  :: c</p>
   <p id="message">↓ a, b, c</p>
   <p id="message">↑ a, c :: b</p>
   <p id="message">↑  :: c</p>
</div>

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:div">The result isn’t a p.</s:assert>
         <s:assert test="h:div/h:p[1] = '↓ c'">The content of p[1] is wrong.</s:assert>
         <s:assert test="h:div/h:p[2] = '↑  :: c'">The content of p[2] is wrong.</s:assert>
         <s:assert test="h:div/h:p[3] = '↓ a, b, c'">The content of p[3] is wrong.</s:assert>
         <s:assert test="h:div/h:p[4] = '↑ a, c :: b'">The content of p[4] is wrong.</s:assert>
         <s:assert test="h:div/h:p[5] = '↑  :: c'">The content of p[5] is wrong.</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.
28 Jan 2025, Norm Tovey-Walsh
Created test.