Adding Location to the xpath

Ask general questions here.
965702
Posts: 14
Joined: Fri Dec 21, 2018 9:49 am

Adding Location to the xpath

Post by 965702 » Tue Feb 19, 2019 9:32 am

Hi Guys

I have the same container 3 times but i only want to find one instance, I was wondering how i add the location to the following xpath:

element[@class='AfxMDIFrame100']//container[@instance='0' and width()=582 and height()=110]

X=0
Y=1132

I can't find anything in the Ranorex user guide, any help would be great.

Regards

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

Re: Adding Location to the xpath

Post by odklizec » Tue Feb 19, 2019 10:16 am

Hi,

You requested almost exactly the same some 2 months ago? :) I answered your initial question here:
adding-size-setting-to-xpath-t13157.html#p52033
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

965702
Posts: 14
Joined: Fri Dec 21, 2018 9:49 am

Re: Adding Location to the xpath

Post by 965702 » Tue Feb 19, 2019 11:05 am

You did :) - I'm just having a few issue combing both the size and location.

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

Re: Adding Location to the xpath

Post by odklizec » Tue Feb 19, 2019 12:15 pm

As mentioned in the original post, without seeing the snapshot (NOT screenshot) of the problematic element(s), it's hard to suggest something reliable. Please provide a Ranorex snapshot of the problematic element so we can evaluate it. Generally speaking, I think that identifying elements based of their size and location is not a very good idea. It will just not work in a long term run.
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

965702
Posts: 14
Joined: Fri Dec 21, 2018 9:49 am

Re: Adding Location to the xpath

Post by 965702 » Tue Feb 19, 2019 1:56 pm

Yep I've attached a snapshot of the container and a screenshot of the flight strip (I can't upload too much as its an Air Traffic system).

Basically I have three of the same strips on screen and I want to identify the one, so I thought why not use the position as it will never move, X = 0 Y = 1332

I am trying to fit into my element:

element[@class='AfxMDIFrame100']//container[@instance='0' and width()=582 and height()=110 location.x=0]

but I'm struggling to understand if I use location.x or x()=.
You do not have the required permissions to view the files attached to this post.

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

Re: Adding Location to the xpath

Post by odklizec » Tue Feb 19, 2019 2:20 pm

Hi,

OK, now I understand. The correct syntax is this:

Code: Select all

//element[@class='AfxMDIFrame100']//container[@instance='0' and width()=582 and height()=110 and cx()=0 and cy()=1132]
This info (sadly missing in new Ranorex user guide), should help you with understanding why cx()/cy() ;)
RanoreXPathFunctions.png
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 Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

965702
Posts: 14
Joined: Fri Dec 21, 2018 9:49 am

Re: Adding Location to the xpath

Post by 965702 » Thu Feb 21, 2019 1:26 pm

Really helpful and exactly what I was looking for.

I was searching the internet for xpath location but couldn't locate.

Regards

965702
Posts: 14
Joined: Fri Dec 21, 2018 9:49 am

Re: Adding Location to the xpath

Post by 965702 » Fri Feb 22, 2019 9:30 am

Out of interest Odklizec is this the same for screen position vs position?

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

Re: Adding Location to the xpath

Post by odklizec » Fri Feb 22, 2019 9:38 am

Hi,

I'm not quite sure what you mean? Basically, x/y is for screen-based position, cx/cy is for client-based position. Or do you mean something else?
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