XPath is a query language for XML or HTML documents.

Studio actions in the "Browsers" group access elements on the page using their path in the HTML markup. The path to the element is specified in the "XPath" parameter of the actions using the XPath language.

To retrieve multiple web elements that have almost identical XPath values, you can organize dynamic XPath replacement using the ROBIN Studio functionality.

By using ROBIN Studio actions with the XPath value stored in a text variable, you can replace the part that varies in the XPath of each web element.

Let’s take a closer look at how dynamic XPath works:

  1. Create a variable with the data type "String" and set its value to the complete XPath of the element, where the varying part will be replaced with some word.
    Example:


    XPath value:



  2. Choose the action "Replace By Pattern" from the "Text" action group.



  3. Fill in the action parameters:
    • Parameter "Text" - specify the variable created earlier that holds the XPath.
    • Parameter "Regex" - specify the regular expression for matching, i.e., the word that needs to be replaced.
    • Parameter "Replacement" - specify the new value for the text to be replaced.
      Example parameter entries:
  4. In the "Result", specify the XPath of the web element whose XPath needs to be changed.
    Example:
  5. After filling in the "Element" parameter of any action in the "Browsers" group with the variable whose XPath is specified for saving the result in the "Replace By Pattern" action, the action will be performed with the modified XPath.
    For a better understanding, let’s consider a use case for dynamic XPath replacement.
  • Нет меток