Skip to main content

JSON bindings

<name> is defined in <jsonRef> by json path "<expression>"

Captures content from a referenced JSON value using the given JSON path expression and associates it with the given name. The value is resolved every time the name is referenced.

Where

  • <name> is the name of the name to associate the captured value to
  • <nodeType> is one of:

    • text to capture the text node
    • node to capture a single node
    • nodeset to capture multiple nodes
  • <sourceRef> is the name of the binding containing the XML source

    • Can be the name of any binding that contains or resolves to XML text, including a web element in which case the text in the element will be dynamically retrieved and used.
  • <expression> is the XPath selector expression

Optionally accepts the @Eager, @Lazy or @Masked annotations.

  • @Eager immediately evaluates the <expression> and binds the result to <name>
  • @Lazy evaluates the <expression> and binds the result to <name> when it is first referenced
  • In the absence of either of the above annotations, <expression> is evaluated every time <name> is referenced
  • @Masked masks the captured value to prevent it from being logged as clear text

Example

  Given the json is "{ "status": "passed" }"
And the status is defined in the json by json path "$.status"
Then the status should be "passed"
I capture the content in <element> by json path "<expression>" as <name>

Captures JSON content from a web element using the given JSON Path expression and binds it to the given name in the global scope.

Where

  • <element> is the name of the element containing the JSON content
  • <expression> is the JSON selector expression
  • <name> is the name to bind the captured value to

Example

  # assuming a web element contains json: { "status": "passed" }
Given the json web element can be located by id "json"
When I capture the content in the json web element by json path "$.status" as the status
Then the status should be "passed"