using normal varaible in XPath
-
- Posts: 18
- Joined: Mon Dec 09, 2019 1:37 pm
using normal varaible in XPath
I have a user code and for user code I am not able to define repository variable. Can I use normal variable inside XPath as @helptext?
Re: using normal varaible in XPath
Hi,
If you are hardcoding xpaths in user code (in Recording module), you must apply the variable like this (where cellCSVValue is the variable):
If you are hardcoding xpaths in user code (in Recording module), you must apply the variable like this (where cellCSVValue is the variable):
Code: Select all
var spanItem = selectPopUpItem.FindSingle<Ranorex.SpanTag>(".//span[@class='mat-option' and @innertext~'" + cellCSVValue + "']", Duration.FromMilliseconds(15000));
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
-
- Posts: 18
- Joined: Mon Dec 09, 2019 1:37 pm
Re: using normal varaible in XPath
Hi,
Thanks for quick response.
My XPath is like "element[@automationid='Test']/?/?/element[@automationid='Cell_User' and @helptext=$varReadOnlyWorkspaceName]"
Can I Use $varReadOnlyWorkspaceName as normal variable in place of repository variable? If yes, than what is the use of Repository variable?
Thanks for quick response.
My XPath is like "element[@automationid='Test']/?/?/element[@automationid='Cell_User' and @helptext=$varReadOnlyWorkspaceName]"
Can I Use $varReadOnlyWorkspaceName as normal variable in place of repository variable? If yes, than what is the use of Repository variable?
Re: using normal varaible in XPath
Hi,
I'm afraid, I don't quite understand what you are trying to achieve? The xpath you posted in how you have it stored in repo, right? Now what exactly you would like to do with it?
I'm afraid, I don't quite understand what you are trying to achieve? The xpath you posted in how you have it stored in repo, right? Now what exactly you would like to do with it?
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
-
- Posts: 18
- Joined: Mon Dec 09, 2019 1:37 pm
Re: using normal varaible in XPath
Hi,
Yes the XPath is stored in Repository.
I have one recording e.g. abc.rxrec. In Recording I have UserCode(Name of method is SelectUser), inside userCode I am accessing the repository item like repo.Cell.Click() (cell is the repository item whose path I have shared in first post). I am planning to use abc.rxrec in multiple projects, so I am thing to make variable inside XPath as bindable so that I can reuse the code.
That's the reason I want to know can I make variable $varReadOnlyWorkspaceName as normal variable and bind it with variable at "SmartFolder" level?
Yes the XPath is stored in Repository.
I have one recording e.g. abc.rxrec. In Recording I have UserCode(Name of method is SelectUser), inside userCode I am accessing the repository item like repo.Cell.Click() (cell is the repository item whose path I have shared in first post). I am planning to use abc.rxrec in multiple projects, so I am thing to make variable inside XPath as bindable so that I can reuse the code.
That's the reason I want to know can I make variable $varReadOnlyWorkspaceName as normal variable and bind it with variable at "SmartFolder" level?
Re: using normal varaible in XPath
Hi,
$varReadOnlyWorkspaceName is normal module variable, so yes, you can bind it to TestCase or SmartFolder data connector or even TC/SF parameter.
Once there is created a module variable (either in action table or repository) and the variable is applied in action table or repository element and the repo element is used in recording module, you should see "unbound variable" in TestSuite, in which the recording module is used. Then you simply bind the variable to TC/SF data connector. The module variable is automatically available also in user code of given recording module.
$varReadOnlyWorkspaceName is normal module variable, so yes, you can bind it to TestCase or SmartFolder data connector or even TC/SF parameter.
Once there is created a module variable (either in action table or repository) and the variable is applied in action table or repository element and the repo element is used in recording module, you should see "unbound variable" in TestSuite, in which the recording module is used. Then you simply bind the variable to TC/SF data connector. The module variable is automatically available also in user code of given recording module.
You do not have the required permissions to view the files attached to this post.
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
-
- Posts: 18
- Joined: Mon Dec 09, 2019 1:37 pm
Re: using normal varaible in XPath
Hi,
Thanks a lot for detailed explanation. Most of the things are clear. Just one confusion $testVar as I can see in screenshot is the "Repository Variable", can I use variable which is normal variable not a repository variable?
Thanks a lot for detailed explanation. Most of the things are clear. Just one confusion $testVar as I can see in screenshot is the "Repository Variable", can I use variable which is normal variable not a repository variable?
Re: using normal varaible in XPath
If you mean a recording variable (created in action table via 'Variables' editor), then yes. If you mean a variable created directly in user code, then no. You must create a Recording variable, which is the only way, how to bind module variables with data connectors/parameters.
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
-
- Posts: 18
- Joined: Mon Dec 09, 2019 1:37 pm
Re: using normal varaible in XPath
Hi,
Thanks a lot. This cleared my doubt .
So what is the advantage of repository variable, if we can achieve same thing using recording variable?
Thanks a lot. This cleared my doubt .
So what is the advantage of repository variable, if we can achieve same thing using recording variable?
Re: using normal varaible in XPath
Hi,
You are welcome.
As for the repository variables, for me, they are the same as recording variables. Once a repository variable is applied in repo element, which is used in recording module, then there is added a new variable also to the list of recording module variables. The only difference is that you don't see all repository variables in the list of recording module variables, but only those, which are actually used in recording module (repo elements with associated repo variables).
You are welcome.
As for the repository variables, for me, they are the same as recording variables. Once a repository variable is applied in repo element, which is used in recording module, then there is added a new variable also to the list of recording module variables. The only difference is that you don't see all repository variables in the list of recording module variables, but only those, which are actually used in recording module (repo elements with associated repo variables).
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