Page 1 of 1

Does Ranorex have some API to modify the xpath string

Posted: Wed Apr 19, 2017 1:38 am
by Fent12
For example:

Code: Select all

string  xpath_str = @"/form[@controlname='Form1']/button[@controlname='button1']"
And i want to modify or add the button attribute to control other button
for example ,i modify to

Code: Select all

   "/form[@controlname='Form1']/button[@controlname='button1111'  and @ControlText = 'fffffff]"
Does ranorex have to some API to do this ?

Re: Does Ranorex have some API to modify the xpath string

Posted: Wed Apr 19, 2017 7:27 am
by odklizec
Hi,

I'm not quite sure, what exactly you want to achieve, but yes, "and" and "or" logical operators are supported in Ranorex xpaths. Please follow this chapter in Ranorex User Guide:
http://www.ranorex.com/support/user-gui ... xpath.html

Re: Does Ranorex have some API to modify the xpath string

Posted: Wed Apr 19, 2017 12:56 pm
by Stub
Early on I was coding up edits to an Xpath string, but lately I've just been adding additional items to the Repository with all the required Xpath components.If I need to adjust one of them dynamically then I use Ranorex Variables e.g. text[@accessiblename=$MyVariableName].

Re: Does Ranorex have some API to modify the xpath string

Posted: Wed Apr 19, 2017 1:02 pm
by odklizec
I believe he is using VS and not Studio? So he is forced to implement his own element handling (repo is not available for VS). This is why I would never consider using VS instead of Ranorex Studio. It's much easier to automate things with Ranorex Studio goodies and without the need to reinvent the wheel ;)

Re: Does Ranorex have some API to modify the xpath string

Posted: Wed Apr 19, 2017 1:10 pm
by Stub
Ah. I missed that. While I vastly prefer the superior text editor of VS, I spend all my time writing Ranorex code in RS nowadays. Repository and Spy integration are just too useful. I had been wondering how to generate the Repository code files from VS without RS doing the job for me, but that's a separate question.