XML asserts
<xmlRef> at xpath "<path>" should[ not] be <blank|empty>
Extracts text from the referenced XML value using the given XPath and checks whether or not it matches a blank or empty string. Reports an assertion error if the match fails.
<xmlRef> at xpath "<path>" should[ not] be <blank|empty>
With custom assertion error message (as of v3.9.0):
<xmlRef> at xpath "<path>" should[ not] be blank @Message("my custom assert fail message")
Without any timeout (as of v3.73.0):
@Timeout('0s') <xmlRef> at xpath "<path>" should[ not] be blank
With custom timeout (as of v3.73.0):
@Timeout('10s') <xmlRef> at xpath "<path>" should[ not] be blank
Where
<xmlRef>is the name of the binding containing the XML source text- Can be the name of any binding that contains or resolves to an XML text value, including a web element in which case the text in the element will be dynamically retrieved and used.
pathis the XPath selector expressionnotnegates the match if included<timeoutSecs>is the timeout period in seconds<wait|timeout>is eitherwaitortimeout
Example
Given the xml is "<result><status>passed</status></result>"
Then the xml at xpath "//result/status" should not be blank
Trimming (since v3.62.0)
- The
@Trimannotation can be used on step to trim strings when comparing
<xmlRef> at xpath "<path>" should[ not] <match> "<expression>"
Extracts text from the referenced XML value using the given XPath and checks that it matches a given expression. Reports an assertion error if the match fails.
<xmlRef> at xpath "<path>" should[ not] <match> "<expression>"
With custom assertion error message (as of v3.9.0):
<xmlRef> at xpath "<path>" should[ not] <match> "<expression>" @Message("my custom assert fail message")
Without any timeout (as of v3.73.0):
@Timeout('0s') <xmlRef> at xpath "<path>" should[ not] <match> "<expression>"
With custom timeout (as of v3.73.0):
@Timeout('10s') <xmlRef> at xpath "<path>" should[ not] <match> "<expression>"
Where
<xmlRef>is the name of the binding containing the XML source text- Can be the name of any binding that contains or resolves to an XML text value, including a web element in which case the text in the element will be dynamically retrieved and used.
pathis the XPath selector expressionnotnegates the match if included<match>is the type of match to perform, one of:befor exact matchcontainfor partial matchstart withfor partial leading matchend withfor partial trailing matchmatch regexfor regex matchmatch xpathfor XML matchmatch json pathfor JSON match, since v1.4.0match templatefor template match, since v2.16.0match template filefor template file match, since v2.16.0
<expression>is the expression to match<timeoutSecs>is the timeout period in seconds<wait|timeout>is eitherwaitortimeout
Example
Given the xml is "<result><status>passed</status></result>"
Then the xml at xpath "//result/status" should be "passed"
Trimming and ignoring case (since v3.62.0)
- The
@Trimannotation can be used on step to trim strings when comparing - The
@IgnoreCaseannotation can be used on step to ignore case when comparing