How to express this Xpath

Ask general questions here.
Fent12
Posts: 11
Joined: Tue Mar 21, 2017 9:38 am

How to express this Xpath

Post by Fent12 » Sat Apr 01, 2017 2:55 am

I want to get a container that his have a button that have attribute @Text= 'Button1'
How to experess this XPATH ,i try a lot of ,but alway raise expection 'Invalid RXPATH'

Fent12
Posts: 11
Joined: Tue Mar 21, 2017 9:38 am

Re: How to express this Xpath

Post by Fent12 » Sat Apr 01, 2017 3:35 am

I understand now,
this can use the xpath 'axis' to get it,
for this question we can use like this '.....container/button[@Text='button3']/parent::*'
this mean select current node parent(container)

But,this only for parent,
if no the parent node,like this:
'.../treeitem/container/container[2]/treeitem[2]/container/container[@caption='abc123']'
if want to search treeitem that it have sub item 'container 'that have @caption='abc123',
I don't know how to get it!

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

Re: How to express this Xpath

Post by odklizec » Sat Apr 01, 2017 10:31 am

Hi,

Please upload a Ranorex snapshot (not screenshot) of the element in question. It's pretty hard to suggest something reliable without seeing at LEAST snapshot. If you need help from the community (or Ranorex support), please provide as much details as possible, including Ranorex snapshot or small sample app. Ranorex snapshot helps us to understand your problem and provide quick and reliable answer. Thanks.
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

satishmohan
Posts: 56
Joined: Wed Jun 10, 2015 4:35 pm

Re: How to express this Xpath

Post by satishmohan » Sun Apr 02, 2017 5:32 pm

Rather using @ we can also write xpath as //container[button[text()='Button1']]

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: How to express this Xpath

Post by Support Team » Sun Apr 02, 2017 9:10 pm

satishmohan wrote:Rather using @ we can also write xpath as //container[button[text()='Button1']]
That won't work with RanoreXPath, which is actually just a subset of XPath and does not support nested queries.

Regards,
Alex
Ranorex Team
.
Image

User avatar
Aracknid
Posts: 342
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: How to express this Xpath

Post by Aracknid » Mon Apr 03, 2017 7:55 pm

./treeitem/container/container[2]/treeitem[2]/container/container[@caption='abc123']/../..

.. = parent, so you can go back to the parent of the parent. Similar to folders in command mode (DOS)

If you have not read this yet, do yourself a favor and read this (I've printed it out and have it by my desk).

http://www.ranorex.com/support/user-gui ... xpath.html

Scroll down and see the section "Advanced RanoreXPath Example"

Aracknid