How to use index properly for a button ?

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

How to use index properly for a button ?

Post by rastek » Tue Aug 19, 2014 2:42 pm

Hi
I have a headache problem I hope someone can help me on this..There is an answer button in the middle of the page I am testing but somehow ranorex clicks another button instead of it..it clicks another Answer button (which is actually not seen on screen initially, only seen after clicking a back arrow button)

I am clicking the right button when recording but it tries to click other button during play (but it can not click bcos other button is not seen on the screen)

Why the hell Ranorex not clicking the button on screen and tried to click another button which is not actually visible on the screen initially ?

I am spying the button but not see an index attribute, I see Class is different for two Answer buttons.

I tried .//div[#'call_answer']//span[@innertext='Answer'][@class='answer_text']
but still clicks the other button ??

There is no index property but I still tried something for using index (as in the QTP)

I search the forum and found those pages

In this page
http://www.ranorex.com/forum/adressing- ... t6716.html
it is adviced to use and
"/dom[@domain='www.mydomain.com' and @browser~'Firefox']"

and in this page
http://www.ranorex.com/forum/combining- ... t5741.html
and in this page
http://www.ranorex.com/forum/variables- ... t3242.html
adviced to use as seperate brackets such as
/treeitem[@accessibledefaultaction='Expand'][1]
or
//tag[@class='highcharts-axis'][1]

Which one is true ? I tried
.//div[#'call_answer']//span[@innertext='Answer'][0]
.//div[#'call_answer']//span[@innertext='Answer'][1]
.//div[#'call_answer']//span[@innertext='Answer'][2]

but no help

also tried
.//div[#'call_answer']//span[@innertext='Answer'][@visible='True']

Which one is true ? I hope someone can help me on this..

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

Re: How to use index properly for a button ?

Post by krstcs » Tue Aug 19, 2014 3:45 pm

Just add the @visible='true' attribute to the XPath.

So, the button's XPath would look like this: "/span[@class='answer_text' and @visible='true']".

This will only find a spantag element that has the class='answer_text' and is visible on the screen.



I would recommend that you take a close look at the element's attributes in Spy and see what attributes are available. Indexes should be used only as a last resort because they are volatile and can change if the developers move things around.
Shortcuts usually aren't...

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

Re: How to use index properly for a button ?

Post by rastek » Wed Aug 20, 2014 7:38 am

Hi krstsc, thanks for replying. I tried adding @visible='true' as you said but did not worked for me.

by the way Class is not Answer but innertext is answer.

When I define the button with class propert only, Ranorex can not find any button.
And when I define the button with class property and with an another property again Ranorex can not find any button.

I am sending spying screenshot for both buttons, you can see what attributes are available maybe you can give me advice.

I hope you can help me more.

Thanks.
You do not have the required permissions to view the files attached to this post.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: How to use index properly for a button ?

Post by Support Team » Fri Aug 29, 2014 12:35 pm

Hi rastek,

I am not exactly sure how the RanoreXPath to the button is defined in your RanorexRepository, but the class attribute should work.

For example:
//div[#'call_answer']//span[@innertext='Answer' and @class='answer_text']

In order to analyze the issue in more detail it would be great to get a Ranorex Snapshot file from your application and the RanroexPath to the button.

Regards,
Bernahrd