Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save testautomation/6ffdf48c928ea30c8d9882e05a23ddef to your computer and use it in GitHub Desktop.
Save testautomation/6ffdf48c928ea30c8d9882e05a23ddef to your computer and use it in GitHub Desktop.

Revisions

  1. testautomation created this gist Mar 5, 2020.
    18 changes: 18 additions & 0 deletions RESTInstance_JSON_string_contains.robot
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    *** Settings ***
    Library REST

    *** Test Cases ***
    Use JSON Schema keyword pattern to test JSON string for substrings
    [Setup] GET https://jsonplaceholder.typicode.com/users/1

    # matches "Leanne Graham" as a substring:
    String response body name pattern="anne Grah"

    # quotes are not necessary, it is still read as a string by the library:
    String response body name pattern=anne Grah

    # pattern supports regular expressions:
    String response body name pattern=(sqilz|Leanne Graham)

    # checking that 'name' does not contain the word:
    String response body name pattern=^((?!asyrjasalo).)*$