Does Ranorex have some API to modify the xpath string

Class library usage, coding and language questions.
Fent12
Posts: 11
Joined: Tue Mar 21, 2017 9:38 am

Does Ranorex have some API to modify the xpath string

Post by Fent12 » Wed Apr 19, 2017 1:38 am

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 ?

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

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

Post by odklizec » Wed Apr 19, 2017 7:27 am

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
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

User avatar
Stub
Posts: 515
Joined: Fri Jul 15, 2016 1:35 pm

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

Post by Stub » Wed Apr 19, 2017 12:56 pm

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].

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

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

Post by odklizec » Wed Apr 19, 2017 1:02 pm

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 ;)
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

User avatar
Stub
Posts: 515
Joined: Fri Jul 15, 2016 1:35 pm

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

Post by Stub » Wed Apr 19, 2017 1:10 pm

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.