Xpath in Web application

What is Difference Between contains() and starts-with() in XPath Funstion?

In XPath, both contains() and starts-with() are used to match partial attribute or text values, but they work differently.

:small_blue_diamond: contains()

  • Checks whether a string contains the specified value anywhere.

  • Useful when the attribute/text has a dynamic middle part.

:small_blue_diamond: starts-with()

  • Checks whether a string starts with the specified value.

  • Useful when the prefix is fixed and the remaining part may be dynamic.