This is a question regarding RanoreXPath.
In summary, I need to directly call the RanoreXPath in my code so I can replace the innertext with a variable. For example the path is usually like //div[@innertext='Options'] but I want to replace 'Options' with a variable, because it needs to change based on the context. Is that possible? I haven't been able to directly access RanoreXPaths in the code before so I'm not sure how to do it.
Is there anyway to call a RanorexPath like this?
For example is there a way to do: repo.//div[@innertext=var].Click();
Where I am clicking on the actual path (with a variable in it) rather than a static Element, so that way I can change it depending on the variable?
Thank you.
Is there a way to edit the RanorexPath in C#?
Re: Is there a way to edit the RanorexPath in C#?
In your repository, look at the Variables... button. You can create a variable that is referenced by the repository item thusly:
//div[@innertext=$MyVariableName]
Then you just set the repository variable MyVariableName to "Options" or whatever.
//div[@innertext=$MyVariableName]
Then you just set the repository variable MyVariableName to "Options" or whatever.
Re: Is there a way to edit the RanorexPath in C#?
Hi,
I would personally avoid referencing xpaths directly in code, because this practice makes the solution messy and potentially unmaintainable in a long run. So I would use Stub's suggestion and eventually, pass the repo element to code via mathod's parameter. If you insists on using xpath in code, then you must do it like this:
I would personally avoid referencing xpaths directly in code, because this practice makes the solution messy and potentially unmaintainable in a long run. So I would use Stub's suggestion and eventually, pass the repo element to code via mathod's parameter. If you insists on using xpath in code, then you must do it like this:
Code: Select all
Ranorex.DivTag searchElement = repo.FindSingle<Ranorex.DivTag>(".//div[@innertext='" + varName + "']",120000);
searchElement .Click();
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