Passing variables in Rx path

Ask general questions here.
manish
Posts: 47
Joined: Fri Aug 10, 2018 12:46 pm

Passing variables in Rx path

Post by manish » Mon Feb 11, 2019 9:50 am

Hello Everyone,

I was trying to automate a button click in a web application where I identify the correct button using its innertext which is passed as a variable in the path as shown below:

Code: Select all

optionName = "Edit";
someRepoItem.FindSingle<ATag>(".//a[@innerText~"+ optionName +"]");
Upon execution, the optionName is replaced as "@edit" instead of "Edit" and an error is thrown as below.

No element found for path './/a[@[email protected]]'.


I have tried it with multiple values for optionName such as Delete and Duplicate. In both these cases, the value is replaced as "@delete" and "duplicate" respectively instead of just "Delete" or "Duplicate".

Has someone faced this situation before. Please help if so.

Thanks
Manish

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 5345
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Passing variables in Rx path

Post by odklizec » Mon Feb 11, 2019 10:11 am

Hi,

The problem is caused by missing quotes in your code. It must be like this...
'"+ optionName +"'
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

manish
Posts: 47
Joined: Fri Aug 10, 2018 12:46 pm

Re: Passing variables in Rx path

Post by manish » Mon Feb 11, 2019 10:15 am

Thanks odklizek.
It works now.