Skip to content
/ .. / .. /
Press Keys on Elements










Press Keys on Elements

Custom key presses may be configured as Context Objects within the Keys block. This enables pressing keys on any Element within an Apptest, regardless if it is an input element or not. This is especially useful for Elements that react to key presses, such as using delete to remove the current item in focus.

Syntax

1
2
3
4
5
ContextObjects {
    Keys {
        <key String>:  <value String>
    }
}

Parameters

  • key - The key press

  • value - The special characters that represent the key press

Example

1
2
3
4
5
ContextObjects {
    Keys {
        delete: "\ue017"
    }
}

Example Stepdef The example below shows the configured delete key within a UI Steps Stepdef.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
stepdef "delete one item"
    v := await ItemView
    v.sendKeys(Keys.key("delete"))
end

// Used as a DSL for special keys to increase caller-side code readability
model Keys
    func key(name)
        return getContextObject("Keys")[name]
    end
end

view ItemView
    elem el := "//*[@id='my-id']"

    action (el) sendKeys := type
end