HI,
I have to identify a table cell based on the comparison with other cells in the same row. I created an xpath for that and it works well for all other condition except for one cell where I am checking whether it is greater than a particular number (_population in the below xpath)
/table//td/table[2]//td[@innertext~$_country]/../td[2]/following-sibling::td/img[@src~$_flag]/../following-sibling::td[@innertext>$_population]/preceding-sibling::td[2]//a
Since I need to get all the values based on the above xpath I am passing this repo item to a function where I am using IList to get all values.
Now the problem that xpath is not taking the _population value which is passing as parameter. I have defined the same in global Parameters and binded this to _population. Except this value all other values are working fine.
When I removed the binded variable and put a static number in the xpath, now its properly Identifying the contrl.
/table//td/table[2]//td[@innertext~$_country]/../td[2]/following-sibling::td/img[@src~$_flag]/../following-sibling::td[@innertext>1000]/preceding-sibling::td[2]//a
How to solve this?
Xpath is not working when binded with a variable
Re: Xpath is not working when binded with a variable
Hi,
Please post a Ranorex snapshot (not screenshot) of the problematic element and a sample solution simulating your problem. It's impossible to tell what;s wrong without seeing the UI (at very least snapshot) and structure of your solution with binded variables and repo. Thanks.
Please post a Ranorex snapshot (not screenshot) of the problematic element and a sample solution simulating your problem. It's impossible to tell what;s wrong without seeing the UI (at very least snapshot) and structure of your solution with binded variables and repo. Thanks.
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
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
Re: Xpath is not working when binded with a variable
Attached.odklizec wrote: ↑Wed Apr 22, 2020 10:58 amHi,
Please post a Ranorex snapshot (not screenshot) of the problematic element and a sample solution simulating your problem. It's impossible to tell what;s wrong without seeing the UI (at very least snapshot) and structure of your solution with binded variables and repo. Thanks.
Last edited by theraviz on Wed Apr 22, 2020 4:04 pm, edited 1 time in total.
Re: Xpath is not working when binded with a variable
Hi,
I think I now understand. The problem is, that the xpath attributes are ALWAYS strings so they cannot be compared as numbers. In fact, '>' in xpath expression means "start with"! To evaluate the innertext as a number, you must adapt the xpath like this:
I think I now understand. The problem is, that the xpath attributes are ALWAYS strings so they cannot be compared as numbers. In fact, '>' in xpath expression means "start with"! To evaluate the innertext as a number, you must adapt the xpath like this:
/table//td/table[2]//td[@innertext~$_country]/../td[2]/following-sibling::td/img[@src~$_flag]/../following-sibling::td[text()>$_population]/preceding-sibling::td[2]//a
Last edited by odklizec on Wed Apr 22, 2020 1:17 pm, edited 1 time in total.
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
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
Re: Xpath is not working when binded with a variable
Thank you. Its resolved