Variables value is not taking

Ask general questions here.
samarthpukale
Posts: 8
Joined: Tue Feb 19, 2019 7:44 am

Variables value is not taking

Post by samarthpukale » Tue Mar 12, 2019 2:31 pm

Hi Team,

As I have passing the value CreationDate(Integer Value say-8) from excel to my recording.

Code: .//div[#'ui-datepicker-div']//table/tbody/tr/td/?/?/a[@innertext=$CreationDate].
It is not taking the value from excel. And when I statically putting
.//div[#'ui-datepicker-div']//table/tbody/tr/td/?/?/a[@innertext='8'] it is taking the proper value.

Please help me in providing values through variables.

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

Re: Variables value is not taking

Post by odklizec » Tue Mar 12, 2019 3:23 pm

Hi,

If you want to pass a module variable to xpath in user code, you must do it like this:

Code: Select all

.//div[#'ui-datepicker-div']//table/tbody/tr/td/?/?/a[@innertext='" + CreationDate +"'"]
BTW, using xpaths directly in code will make your test suite unreadable and very hard to maintain! You should always pass the UI elements to code via repository and repoiteminfo/adapter parameters.
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

samarthpukale
Posts: 8
Joined: Tue Feb 19, 2019 7:44 am

Re: Variables value is not taking

Post by samarthpukale » Wed Mar 13, 2019 7:23 am

I am not passing the module variable to xpath in user code.
And where is the variable key in this xpath which you have given.
This is not working

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

Re: Variables value is not taking

Post by odklizec » Wed Mar 13, 2019 8:34 am

Hi,

Well, your initial post indicated, that you are trying to pass a variable to xpath in code? If you simply trying to pass a variable (filled from excel) to the repository xpath, then you must have the variable binded to the proper data connector. Unfortunately, it's impossible to tell what's wrong, without seeing the test suite. Can you share it? My guess is that the variable is either not connected with data connector or connected to wrong data connector or parameter?
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