What is the difference between using @ and # in a path ?

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
rastek
Posts: 157
Joined: Wed Aug 06, 2014 12:00 pm

What is the difference between using @ and # in a path ?

Post by rastek » Wed Aug 20, 2014 8:30 am

Hi
I am still learning Xpath structure.

I dont know difference between using @ and # in a path. Can anybody tell me that ?

Most of my records start with #,

If I write something like below is it true ? I mean if I use @ and then # in same path.
(actually it is not working, ranorex can not find anything)

.//div[@class='call_window incoming']/div[#'call_answer']//span[@innertext='Answer']

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: What is the difference between using @ and # in a path ?

Post by krstcs » Wed Aug 20, 2014 1:35 pm

@ is the symbol for an attribute. It is followed by the name of the attribute being searched for. For example, "@innertext" tells Ranorex to use the InnerText attribute to identify the element. It is also followed by the "='<Value>'" text to indicate the expected value. For example, a button with text of "OK" would look like this: /button[@text='OK']


The # symbol indicates that Ranorex should search for the ID attribute ONLY. The ID attribute's value MUST be UNIQUE. It is SIMILAR (but not exactly the same) to using the "@id='<Value>'" attribute. However, the '#' symbol denotes that the ID being search for is UNIQUE and that it can be HASHED in a way that makes it easier and faster for Ranorex to find. Again, this symbol ONLY applies to the ID attribute. It cannot be used with any other attribute. For example, a button with the ID of "OkButton" would look like either of these: /button[#'OkButton'] OR /button[@id='OkButton']

If you have a choice between using the @id or #, use #.
Shortcuts usually aren't...