Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save testautomation/0055823cf9e4eec6d241d99d8327e4af to your computer and use it in GitHub Desktop.
Save testautomation/0055823cf9e4eec6d241d99d8327e4af to your computer and use it in GitHub Desktop.
XML - Elements Should Match vs. Elements Should Be Equal (Robot Framework / #robotframework)
*** Settings ***
Library    XML



*** Test Cases ***
XML Elements Should Match
    ${a}                Parse Xml  <units>mm[Hg]</units>
    ${b}                Parse Xml  <units>mm[Hg]</units>
    
                        Elements Should Match  ${a}  ${b}


XML Elements Should Be Equal
    ${a}                Parse Xml  <units>mm[Hg]</units>
    ${b}                Parse Xml  <units>mm[Hg]</units>
    
                        Elements Should Be Equal  ${a}  ${b}
@testautomation
Copy link
Author

testautomation commented Oct 29, 2019

result from above example

XML Elements Should Match                                             | FAIL |
Different text: 'mm[Hg]' does not match 'mm[Hg]'
------------------------------------------------------------------------------
XML Elements Should Be Equal                                          | PASS |

Pattern matching

Some keywords, for example Elements Should Match, support so called
[http://en.wikipedia.org/wiki/Glob_(programming)| glob patterns where:

PATTERN MATCH
* matches any string, even an empty string
? matches any single character
[chars] matches one character in the bracket ⚠️ ⚠️ ⚠️
[!chars] matches one character not in the bracket
[a-z] matches one character from the range in the bracket
[!a-z] matches one character not from the range in the bracket

Unlike with glob patterns normally, path separator characters / and
\ and the newline character \n are matches by the above wildcards.

Support for brackets like [abc] and [!a-z] is new in Robot Framework 3.1

For details check XML Library Docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment