Click on Exact Match

The following command is giving my some problems because the text Retirar appears 2 times.

  • one time appears the text Retirar invitacion
  • and the other time appears just Retirar

For this reason I’d like to replace CONTAINS for Exact Match.

How should I write the following command to find the exact match?

      "Command": "click",
      "Target": "//*[text()[contains(.,'Retirar')]]",
      "Value": ""



You can add the number of element to click the correct element

      "Command": "click",
      "Target": "xpath=(//*[text()[contains(.,'Retirar')]])[1]",
      "Value": ""

With [1] you must choice the first element with this xpath you can change with [2] or other number.

It worked! thanks @newuserkantu !

1 Like

@newuserkantu one additional question

If i wanted to do the same but instead of CONTAINS I wanted to make sure that the text starts with that chain of text – how should it be done?

      "Command": "click",
      "Target": "xpath=(//*[text()[ **startswith** (.,'Estado')]])[1]",
      "Value": ""
  • The text that is being looked for is Estado
  • and Estado has to appear at the beginning of the match

This would find a match because the text starts with the word Estado

Estado ON

This wouldn’t return a match because the text doesn’t start with the word Estado

Alarma de Estado es ON

I have to replace StartsWith from the command and what should I type instead? Thnx!

I suggest you of reverse the logical of your macro with an if

If your marcro contains xpath with “Alarma de Estado es ON” pause or stop (do not click)

You can use !StatusOK to know if locator is found.

If your macro do not contains xpath with “Alarma de Estado es ON” continue work.

You can use this command too storexpathcount to know if the xpath with “Alarma de Estado es ON” is present or not.