TestProject Forum

Using parameters in xpath

HI!
Sorry for my english :slight_smile: translate through Google
help me please

  1. get text > get the parameter 1234 (dynamic)
  2. to take one by one 1, 2, 3, 4
  3. click on the button
    xpath://android.widget.TextView[@text = ‘1’]
    xpath://android.widget.TextView[@text = ‘2’]
    xpath://android.widget.TextView[@text = ‘3’]
    xpath://android.widget.TextView[@text = ‘4’]
    1 - i did
    2 - do not know how
    3 - is it possible to use parameters in xpath://android.widget.TextView[@text = ‘parameter’]
    Thanks

Hello @zeleznov.sergey,

About your questions:

  • The “String Utils” addon provides a lot of useful actions for manipulating Strings, such as: “Get the string length”, “Split string with regex”, “Get substring in range” etc. I would recommend splitting the string by regex and retrieving the values using the “Get substring in range” action. you can install the “String Utils addon” and review its actions form here: https://app.testproject.io/#/addons/community

  • Yes, it is possible to parameterize XPath locators, you can edit the element, and click on the plus button to add a parameter, here is an example for you:

1 Like

thanks for the answer