XML

The XML testfunctions allow testing XML files with support for XPath queries, namespace handling, regex matching, and timestamp tolerance.

All XML testfunctions support:

  • XPath expressions for element selection

  • Namespace support via optional namespaces parameter

  • Placeholder system for regex patterns and timestamp tolerance (using {{ placeholder_name }})

  • Case sensitivity control in text/attribute matching

  • Wildcard modes (any/all) for multiple element matching

Features:

  • Regex Support: Use regex_match: true or placeholders like {{ regex_pattern }}

  • Timestamp Tolerance: Use placeholders like {{ timestamp_with_tolerance }} for flexible timestamp comparison

  • Multiple Elements: Handle multiple matching elements with wildcard_mode (any/all)

  • Namespaces: Support XML namespaces with prefix mapping

Function Name

S

Description

Parameters

element_exists

Tests if XML element exists at specified XPath

dst (str), xpath (str), namespaces* (dict)

element_text_matches

Tests if XML element text content matches expected value with placeholder support for regex and timestamp tolerance

dst (str), xpath (str), expected_text (str), regex_match* (bool), case_sensitive* (bool), wildcard_mode* (str), namespaces* (dict)

attribute_matches

Tests if XML element attribute matches expected value with regex and timestamp tolerance support

dst (str), xpath (str), attribute_name (str), expected_value (str), regex_match* (bool), case_sensitive* (bool), namespaces* (dict)

element_count

Tests the number of XML elements matching XPath expression

dst (str), xpath (str), expected_count (int), comparison_type* (str), namespaces* (dict)

xpath_result_matches

Tests if XPath expression result matches expected value (text/number/boolean)

dst (str), xpath (str), expected_result (str/int/float/bool), result_type* (str), namespaces* (dict)

namespace_matches

Tests if XML namespace declarations match expected namespaces

dst (str), expected_namespaces (dict), check_mode* (str)