Can not simplfy xpath of a button

Ask general questions here.
rastek
Posts: 182
Joined: Wed Aug 06, 2014 12:00 pm

Can not simplfy xpath of a button

Post by rastek » Mon Dec 28, 2020 10:09 pm

I am automating a SAP application and I have a button with xPath
element[@controlid='100']/element[@class='Shell Window Class' and @instance='0']//element[@controlid='59648' and @class='AfxFrameOrView140']//toolbar[@class='ToolbarWindow32']/button[@text='Order']

I tried to use like this but it does not work
.//button[@text='Order']

alsı this doesnt work
.//button[0] or .//button[XX]

I wonder why this method does not work as its work in web (in web applications also sometimes doesnt work)
what is the rule here ? How can I simplfy thi button so that I can automate without using ids and so on.

User avatar
Mike K
Posts: 10
Joined: Wed Jun 28, 2017 5:58 pm

Re: Can not simplfy xpath of a button

Post by Mike K » Wed Dec 30, 2020 1:52 pm

Hi,

It could simply be your nomenclature. There shouldn't be any '.' in front of '//'. Try the following path:

element[@controlid='100']/element[@class='Shell Window Class' and @instance='0']//element[@controlid='59648' and @class='AfxFrameOrView140']//toolbar[@class='ToolbarWindow32']//button[@text='Order']

Hopefully, this should do the trick.

rastek
Posts: 182
Joined: Wed Aug 06, 2014 12:00 pm

Re: Can not simplfy xpath of a button

Post by rastek » Sun Feb 14, 2021 5:28 pm

İt doesnt work. Ranorex puts . even if you dont use it