Features: selenium

selenium-026

Tests that key up and key down work for named keys.

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 SHIFT .
find $message by id = "message" .
output xpath "string($message)" to result .

key up SHIFT .
find $message by id = "message" .
output xpath "string($message)" to result .

key down ALT .
key down F2 .
find $message by id = "message" .
output xpath "string($message)" to result .

key up F2 .
find $message by id = "message" .
output xpath "string($message)" to result .

key up ALT .
find $message by id = "message" .
output xpath "string($message)" to result .
      </p:inline>
      </p:with-input>
   </cx:selenium>
   <p:for-each>
      <p:wrap-sequence wrapper="keys"/>
   </p:for-each>
   <p:wrap-sequence wrapper="wrapper"/>
</p:declare-step>

Result

<wrapper xmlns:t="http://xproc.org/ns/testsuite/3.0">
   <keys>↓ shift Shift</keys>
   <keys>↑  :: Shift</keys>
   <keys>↓ alt Alt, alt F2</keys>
   <keys>↑ alt Alt :: alt F2</keys>
   <keys>↑  :: Alt</keys>
</wrapper>

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="wrapper">The result isn’t a wrapper.</s:assert>
         <s:assert test="count(wrapper/keys) = 5">The number of keys is wrong.</s:assert>
         <s:assert test="wrapper/keys[1] = '↓ shift Shift'">The keys are wrong</s:assert>
         <s:assert test="wrapper/keys[2] = '↑  :: Shift'">The keys are wrong</s:assert>
         <s:assert test="wrapper/keys[3] = '↓ alt Alt, alt F2'">The keys are wrong</s:assert>
         <s:assert test="wrapper/keys[4] = '↑ alt Alt :: alt F2'">The keys are wrong</s:assert>
         <s:assert test="wrapper/keys[5] = '↑  :: Alt'">The keys are 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.
09 Feb 2025, Norm Tovey-Walsh
Created test.