Cannot click Ranorex identified element in html

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
timmon
Posts: 3
Joined: Mon Apr 11, 2016 10:43 am

Cannot click Ranorex identified element in html

Post by timmon » Mon Apr 11, 2016 11:17 am

Hi,

I'm having a Single Page App and I'm trying to click a link from menu. Drop down list is generated by javascript which contains div elements. After executing report says "Element '{SpanTag:Documents}' does exist" but when it should be clicked mouse goes in to top left corner. No error message given

Html
<a href data-bind=click:function(data, event)...>
<span data-testkey="typetree">Documents</span>
</a>

Code example 1
Ranorex.SpanTag spani = "//span[@innertext='Documents' and @data-testkey='typetree']";
Validate.Exists(spani); //Does exists
spani.Click();

Code example 2
Validate.Exists("//span[@innertext='Documents' and @data-testkey='typetree']"); //Does exists
Ranorex.Unknown selectType = "//span[@innertext='Documents' and @data-testkey='typetree']";
selectType.Click();

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

Re: Cannot click Ranorex identified element in html

Post by odklizec » Mon Apr 11, 2016 12:13 pm

Hi,

I'm afraid, there is not enough information in your post to provide a reliable answer. Please answer below questions:

Ranorex version?
Have you tried using recording modules instead of code?
Could you please upload a Ranorex snapshot (not screenshot) of the element in question?
Could you please post a sample (working) HTML code, we can try (for example at http://www.w3schools.com)?

My guess is, that the element in question is either not unique and Ranorex tries to click the wrong one. Eventually, the element is not entirely loaded/ready at a time when Ranorex tries to click the element?

You see, with HTML (any dynamically loaded GUI), it may happen that Ranorex tries to click the element before the element is fully loaded. It may already be visible, but probably not ready yet. In this case, you may need to add some delays, or even better, waitfor actions here or there.

At first, I would suggest to check the xpath with Ranorex Spy. If it returns more than one elements, then you need to fix your xpath.

If it returns (highlights) just one element, then try to add a delay between expanding the dropdown and actual click.

From your code, it seems as if you trying to click the element without expanding the dropdown? Or is there just missing line in your example?
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

timmon
Posts: 3
Joined: Mon Apr 11, 2016 10:43 am

Re: Cannot click Ranorex identified element in html

Post by timmon » Mon Apr 11, 2016 12:52 pm

Thank you for quick response.

Ranorex version is 5.2.4. Spy show's that xpath is unique. I could provide for you an url if you could see the actual page. It only requires login and clicking a plus icon to open menu. If it is ok I can send you credentials?

BR,
Timo

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

Re: Cannot click Ranorex identified element in html

Post by odklizec » Mon Apr 11, 2016 1:02 pm

Well, if it's OK for you to send the credentials over web? ;) Maybe send them via PM.

Anyway, 5.2.4 is pretty old and no longer supported version. I would strongly suggest to try latest 5.4.6.
Last edited by odklizec on Mon Apr 11, 2016 1:06 pm, edited 1 time in total.
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

timmon
Posts: 3
Joined: Mon Apr 11, 2016 10:43 am

Re: Cannot click Ranorex identified element in html

Post by timmon » Mon Apr 11, 2016 1:06 pm

I'm sorry but I can't provide credentials in here but could I send those in some little bit more secure way?

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

Re: Cannot click Ranorex identified element in html

Post by odklizec » Mon Apr 11, 2016 1:13 pm

Sure. I would suggest to create a temporary credentials and send them via PM (private message).
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

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

Re: Cannot click Ranorex identified element in html

Post by odklizec » Tue Apr 12, 2016 2:15 pm

Problem solved by replacing below line...

Code: Select all

Ranorex.SpanTag spani = "//span[@innertext='Documents' and @data-testkey='typetree']";
with this one:

Code: Select all

repo.Sovelia.DictionaryList.TryFindSingle<Ranorex.SpanTag>(".//span[@innertext='"+type+"' and @data-testkey='typetree' and @visible='true']",out spani);
Where DictionaryList is a repo element, containing menu elements. So it's faster and much more reliable to find unique span element.
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