Skip to navigation

Navigation and interaction, written as tests

Each example on this page shows one documented procedure four ways:

TabWhat the file holds
ProseThe documentation as a reader sees it, with no test statements.
DetectedThe same prose inside a test statement. Doc Detective’s default detection turns the links, bold text, and quoted text into steps.
InlineThe same prose with a step statement after each instruction, and detection off.
StandaloneA spec file, in JSON or YAML, with no documentation source.

Every variant is a real file that Doc Detective runs, and a check confirms that the variants resolve to the same steps. For how each mode works, see Detected tests, Inline tests, and Standalone tests.

Open a page, type, and check the result

This procedure uses goTo, click, type, and find.

prose.md
# Echo text back
1. Go to [the type echo page](http://localhost:8092/type-echo.html).
2. Click **Type here:**.
3. Type "Hello, Doc Detective".
4. Check that the page shows **Hello, Doc Detective** below the field.

What detection finds

In every format, default detection resolves the prose to six steps:

ProseDetected steps
Go to a linkgoTo the URL, then checkLink the same URL
Click a bold phraseclick the phrase, then find the same phrase
A bold phrasefind the phrase

Detection matches each link and bold phrase against every default rule. A link after “Go to” is both opened and checked, and a bold phrase after “Click” is both clicked and found. The inline and standalone variants list only the four steps the procedure needs.

In DITA, the quoted text and the <b> element follow the shared rules, so DITA detects the same steps as the other formats. A <uicontrol> element is DITA’s own way to mark the control to click.

Wait for a slow page to load

This procedure uses the object form of goTo with origin, a relative url, params, surface, timeout, and every waitUntil condition. It also uses find with a /regex/ in elementText, and wait with a number.

Two checkLink steps show both shapes of each option. The first sets statusCodes as a list and headers as an object, with a timeout. The second sets origin, params, a single status code, and headers as a string with one Name: value header per line.

prose.md
# Wait for a slow page
1. Go to [the wait delay page](http://localhost:8092/wait-delay.html).
2. Wait until the page shows **Loaded after 2 seconds**.
3. Click **Trigger delayed action**.
4. Wait half a second for the action to finish.
5. Check that the page shows **Action complete!**.
6. Confirm that [the server's status endpoint](http://localhost:8092/status/200) and [the API health check](http://localhost:8092/api/health) respond.

What detection finds

No default rule detects a pause, so every detected variant carries a step statement for the wait. Detection resolves the rest of the prose to the string forms:

ProseDetected steps
Go to a linkgoTo the URL, then checkLink the same URL
A bold phrasefind the phrase
Click a bold phraseclick the phrase, then find the same phrase
Any other linkcheckLink the URL with the default status codes

Detected steps can’t set waitUntil, query parameters, a regular expression, or accepted status codes. Write a step statement, as the inline variants do, when a page loads slowly or a link returns a status outside the defaults.

Fill in a form by element attributes

This procedure locates elements by their attributes, not only by a CSS selector: elementText, elementId, elementTestId, elementAria, elementClass (as a string and as a list), and elementAttribute. It uses them on three actions:

  • find with moveTo, timeout, surface, click as true and as a button name, and type as an object, a list, and a string.
  • type with a surface and a waitUntil that waits for the network and the DOM to go idle and for an element to appear.
  • click with timeout, and surface as an engine name and as an object.

For every field, see the find, type, and click schemas.

prose.md
# Fill in a form by element attributes
1. Go to [the element test page](http://localhost:8092/enhanced-elements.html).
2. Find the **Submit by ID** button near the top of the page.
3. Click the username field and type "kittens".
4. Click the password field and type "hunter2".
5. Click the contact email field and type "you@example.com".
6. Type "-cat" at the end of the username.
7. Type "docs" in the search field, and wait for the page to settle.
8. Check that the **Submit Order** button is enabled.
9. Click **Save**.
10. Click **Login Submit**.
11. Confirm that the page shows **Operation successful**.

What detection finds

Detection matches a bold phrase by its visible text, so it finds Submit by ID and Submit Order. It can’t check an ID, a test ID, a class, or an attribute. Each Type "…" becomes a type step with no target, because the fields have no visible label to bold. The inline variants find each field by its attributes and type into it.

Search with toolbar icons

This procedure finds icons by a picture of them, with elementImage on the waitUntil.find of goTo, on click, and on find. The picture comes as base64 with a threshold, as a path with a color, and as a path string. The find step sets click to an object with button and duration. It also uses type with an array that ends in the $ENTER$ key, and with an object that sets keys, selector, and inputDelay.

prose.md
# Search from the toolbar
1. Go to [the toolbar page](http://localhost:8092/find-image.html).
2. Click the magnifying-glass icon next to the search box.
3. Type "doc detective" and press Enter.
4. Check that the status bar shows **doc detective**.
5. Type "-docs" at the end of the search box.
6. Check that the status bar shows **doc detective-docs**.
7. Right-click the save icon and hold the button for half a second.
8. Check that the status bar records the right-click.

The icon pictures, search.svg and save.svg, sit in the example’s folder, and the base64 value is save.svg encoded. A relative elementImage path resolves against the file that holds the step. See Find elements by image.

What detection finds

No default rule matches an icon by its picture, so every detected variant carries step statements for the two icon steps. It also carries a goTo statement, so those steps open the page even when detection is off. Detection turns each Type "…" into a type step and each bold phrase into a find step. The detected type steps send the quoted text only, without the $ENTER$ key or the input delay.

Drag widgets and scroll the page

This procedure uses dragAndDrop twice. The first drag sets a text source, an object target with a timeout, and a duration. The second sets an object source located by text, class, and attributes, a selector string target, and a surface. It also uses click with selector, button, and a duration that holds the press. swipe appears in all three forms: a direction, an object with direction, distance, and duration, and a point-to-point object with from and to. The two object forms also name the surface to swipe.

prose.md
# Drag widgets and scroll the page
1. Go to [the drag and drop page](http://localhost:8092/drag-drop-test.html).
2. Drag **Table** onto **Drop Zone 1**.
3. Check that **Table (dropped)** appears in the drop zone.
4. Press and hold **Chart** for one second.
5. Drag **Chart** onto **Drop Zone 2**.
6. Check that **Chart (dropped)** appears in the second drop zone.
7. Swipe up to scroll toward the bottom of the page.
8. Swipe down a third of the screen to scroll back.
9. Swipe from the middle of the page toward the top.

What detection finds

No default rule detects a drag, a press and hold, or a swipe, so every detected variant carries step statements for them. A goTo statement opens the page even when detection is off. Detection adds a find step for each bold phrase. Those steps confirm that Table, Drop Zone 1, Chart, and Drop Zone 2 are on the page before the steps that use them.

Enter text in a DITA task

This procedure uses DITA’s own detection rules. They turn an <xref> into goTo and checkLink steps, a <userinput> typed into a <uicontrol> into a type step, a <wintitle> into a find step, and a <link> into a checkLink step.

prose.dita
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="nav-dita-controls">
<title>Enter text in a field</title>
<taskbody>
<steps>
<step><cmd>Open <xref href="http://localhost:8092/type-echo.html" scope="external" format="html">the type echo page</xref>.</cmd></step>
<step><cmd>Check that the page title reads <wintitle>Type Echo Test Page</wintitle>.</cmd></step>
<step><cmd>Type <userinput>Hello, DITA</userinput> into the <uicontrol>Type here:</uicontrol> field.</cmd></step>
<step><cmd>Check that the page shows <b>Hello, DITA</b> below the field.</cmd></step>
</steps>
</taskbody>
<related-links>
<link href="http://localhost:8092/index.html" scope="external" format="html"><linktext>Test server home</linktext></link>
</related-links>
</task>

This example is DITA only, plus the standalone spec, because <wintitle>, <userinput>, <uicontrol>, and <link> have no equivalent in the other formats.

What detection finds

DITA sourceDetected steps
<xref> after “Open”goTo the URL, then checkLink the same URL
<wintitle>find the title text on the page
Type <userinput>…</userinput> into the <uicontrol>…</uicontrol>type the <userinput> text into the field whose accessible name is the <uicontrol> text, with elementAria, then find the control
<b>find the text
<link> in <related-links>checkLink the URL

The <related-links> section comes after <taskbody>, so the test has no test end statement and runs to the end of the topic. That way the detected test includes the related link. The inline variant can’t place a step statement after the link, so the inline and standalone variants leave it out.

How the permutation examples work

Each example in the sections below varies one setting, or one deliberate combination, in a short procedure. Detected variants carry a step statement for the varied step when default detection can’t produce it. They also carry a goTo statement, so they still open the page with detection off.

For clicking, typing, dragging, uploading, iframes, swiping, waiting, and checking links, see Interaction options.

goTo permutations

Each example opens a page with one goTo option set, then checks the page with find.

waitUntil.networkIdleTime: 500

Varies: goTo.waitUntil.networkIdleTime · Value: 500 · Effect: the step waits until the page has made no network requests for 500 milliseconds, so content that a request loads is there.

prose.md
# Wait for network requests to finish
1. Go to [the network test page](http://localhost:8092/waitUntil-test-network.html).
2. Check that the page shows **Content loaded from API**.

waitUntil.domIdleTime: 1000

Varies: goTo.waitUntil.domIdleTime · Value: 1000 · Effect: the step waits until the DOM has stopped changing for one second.

prose.md
# Wait for the page to stop changing
1. Go to [the DOM mutations page](http://localhost:8092/waitUntil-test-dom-mutations.html).
2. Check that the page shows **All mutations complete**.

waitUntil.find

Varies: goTo.waitUntil.find · Value: { "selector": ".dashboard-loaded" } · Effect: the step waits until an element that matches the selector appears.

prose.md
# Wait for an element to appear
1. Go to [the late element page](http://localhost:8092/waitUntil-test-late-element.html).
2. Check that the page shows **Dashboard**.

waitUntil: { networkIdleTime, domIdleTime, find }

Varies: goTo.waitUntil · Value: networkIdleTime, domIdleTime, and find together, with timeout: 10000 · Effect: the step waits until every condition holds, and fails if they don’t all hold within 10 seconds.

prose.md
# Wait for the network, the page, and an element
1. Go to [the late element page](http://localhost:8092/waitUntil-test-late-element.html).
2. Check that the page shows **System operational**.

timeout: 60000

Varies: goTo.timeout · Value: 60000 · Effect: the step allows the page up to 60 seconds to load.

prose.md
# Give a slow page more time to load
1. Go to [the static page](http://localhost:8092/waitUntil-test-static.html).
2. Check that the page shows **Static Page**.

origin + url

Varies: goTo.origin · Value: "http://localhost:8092" with url "/enhanced-elements.html" · Effect: the step joins origin and the relative url into the address it opens.

prose.md
# Open a page by its path
1. Go to [the element test page](http://localhost:8092/enhanced-elements.html).
2. Check that the page shows **Submit by ID**.

newTab: true

Varies: goTo.newTab · Value: true · Effect: the step opens the page in a new tab and makes it the active tab.

prose.md
# Open a page in a new tab
1. Go to [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Open [the child page](http://localhost:8092/multi-tab-child.html?page=docs) in a new tab.
3. Check that the new tab shows **PAGE docs**.

newWindow: true

Varies: goTo.newWindow · Value: true · Effect: the step opens the page in a new window and makes it the active window.

prose.md
# Open a page in a new window
1. Go to [the multi-tab page](http://localhost:8092/multi-tab.html).
2. Open [the child page](http://localhost:8092/multi-tab-child.html?page=w1) in a new window.
3. Check that the new window shows **PAGE w1**.

find locator permutations

Each example finds one element with one locator field of find. For every field, see the find schema.

selector

Varies: find.selector · Value: "#submit-button" · Effect: the step finds the element that matches the CSS selector.

prose.md
# Find an element by its selector
1. Go to [the element test page](http://localhost:8092/enhanced-elements.html).
2. Find the **Submit by ID** button.

elementText: "Submit Order"

Varies: find.elementText · Value: "Submit Order" · Effect: the step finds the element whose whole visible text is Submit Order.

prose.md
# Find an element by its text
1. Go to [the element test page](http://localhost:8092/enhanced-elements.html).
2. Find the **Submit Order** button.

elementText: "/^Submit Pri/"

Varies: find.elementText · Value: "/^Submit Pri/" · Effect: the step finds the first element whose visible text matches the regular expression.

prose.md
# Find an element by a text pattern
1. Go to [the element test page](http://localhost:8092/enhanced-elements.html).
2. Find the **Submit Primary** button.

elementId

Varies: find.elementId · Value: "submit-button" · Effect: the step finds the element with that id attribute.

prose.md
# Find an element by its ID
1. Go to [the element test page](http://localhost:8092/enhanced-elements.html).
2. Find the **Submit by ID** button.

elementTestId

Varies: find.elementTestId · Value: "login-form-submit" · Effect: the step finds the element with that data-testid attribute.

prose.md
# Find an element by its test ID
1. Go to [the element test page](http://localhost:8092/enhanced-elements.html).
2. Find the **Login Submit** button.

elementAria

Varies: find.elementAria · Value: "Save document button" · Effect: the step finds the element with that accessible name.

prose.md
# Find an element by its accessible name
1. Go to [the element test page](http://localhost:8092/enhanced-elements.html).
2. Find the **Save** button.

elementClass: "btn-large"

Varies: find.elementClass · Value: "btn-large" · Effect: the step finds the first element that has the class.

prose.md
# Find an element by one class
1. Go to [the element test page](http://localhost:8092/enhanced-elements.html).
2. Find the **Login Submit** button.

elementClass: [ … ]

Varies: find.elementClass · Value: ["btn", "btn-secondary", "btn-large"] · Effect: the step finds the first element that has every class in the list.

prose.md
# Find an element by several classes
1. Go to [the element test page](http://localhost:8092/enhanced-elements.html).
2. Find the **Large Secondary** button.

elementAttribute: { "data-count": "5" }

Varies: find.elementAttribute · Value: { "data-count": "5" } · Effect: the step finds the element whose attribute has that value.

prose.md
# Find an element by an attribute value
1. Go to [the element test page](http://localhost:8092/enhanced-elements.html).
2. Find the **Count: 5** button.

elementAttribute: { "disabled": true }

Varies: find.elementAttribute · Value: { "disabled": true } · Effect: the step finds the first element that has the attribute, whatever its value.

prose.md
# Find an element by an attribute's presence
1. Go to [the element test page](http://localhost:8092/enhanced-elements.html).
2. Find the **Disabled Button** button.

elementImage: "save.svg"

Varies: find.elementImage · Value: "save.svg" · Effect: the step finds the spot on the page that looks like the picture in the file.

prose.md
# Find an element by an image file
1. Go to [the toolbar page](http://localhost:8092/find-image.html).
2. Find the save icon in the toolbar.

elementImage: { path, threshold }

Varies: find.elementImage · Value: { "path": "save.svg", "threshold": 0.95 } · Effect: the step finds the picture and counts only a match that scores 0.95 or higher.

prose.md
# Find an element by an image with a threshold
1. Go to [the toolbar page](http://localhost:8092/find-image.html).
2. Find the save icon in the toolbar.

find action permutations

Each example adds one follow-up action or limit to a find step.

click: true

Varies: find.click · Value: true · Effect: the step left-clicks the element after it finds it.

prose.md
# Find an element and click it
1. Go to [the click counter page](http://localhost:8092/find-click.html).
2. Find **Count clicks** and click it.
3. Check that the button counted one left click.

type: "Hello"

Varies: find.type · Value: "Hello" · Effect: the step types the keys into the element after it finds and clicks it.

prose.md
# Find a field and type in it
1. Go to [the type echo page](http://localhost:8092/type-echo.html).
2. Find the **Type here:** field, click it, and type `Hello`.
3. Check that the page shows **Hello** below the field.

moveTo: true

Varies: find.moveTo · Value: true · Effect: the step scrolls the element into view and moves the cursor to it.

prose.md
# Find an element and scroll to it
1. Go to [the toolbar page](http://localhost:8092/find-image.html).
2. Scroll down to the icon at the bottom of the page.

timeout: 10000

Varies: find.timeout · Value: 10000 · Effect: the step keeps looking for the element for up to 10 seconds.

prose.md
# Give a late element more time
1. Go to [the late element page](http://localhost:8092/waitUntil-test-late-element.html).
2. Wait for the status line to read **System operational**.