version: 5.7.7
session: 682f62a1811bd5a322c0e70b
steps:
  - commands:
    - command: run
      file: testdriver/snippets/login.yaml
  - prompt: scroll until text testdriver socks
    commands:
      - command: focus-application
        name: Google Chrome
      - command: scroll-until-text
        text: testdriver socks
        direction: down
        method: keyboard
  - prompt: assert testdriver socks appears on screen
    commands:
      - command: focus-application
        name: Google Chrome
      - command: assert
        expect: TestDriver Socks appears on screen

Description

The scroll-until-text command is used to scroll the screen in a specified direction until the specified text is found. This is useful for navigating to elements that aren’t initially visible on the screen.

Arguments

ArgumentTypeDescription
textstringThe text to find on the screen. Longer and unique are better. Note this is case sensitive
directionstringThe direction to scroll. Available directions are: up, down, left, right.
distancenumber(Optional) The maximum number of pixels to scroll before giving up. Default is 300.
methodenum(Optional) The matching algorithm to use. Possible values are keyboard (default) and mouse.

Example usage

command: scroll-until-text
text: Sign Up
direction: down
method: keyboard
distance: 500

Protips

  • The keyboard method will trigger a “find” action (ex: Command + F) to locate the text, while the mouse method will use a mouse scroll action only.
  • Use unique and specific text to improve detection accuracy.
  • Adjust the distance value to control how far the command scrolls before giving up.
  • If you don’t specify a distance, the command will scroll 300 pixels at a time, giving up after 5 attempts.

Gotchas

  • If the text can’t be located within the specified distance, the command will fail.
  • Ensure the text is visible and matches exactly, as variations in font size, style, or screen resolution may affect detection accuracy.
  • Note that text is case-sensitive, so Sign Up and sign up would be treated as different strings.

Notes

  • The scroll-until-text command is ideal for navigating to elements that are off-screen and can’t be located using other commands.
  • This command supports both vertical and horizontal scrolling for flexible navigation.