Page 1 of 1

Cannot click Ranorex identified element in html

Posted: Mon Apr 11, 2016 11:17 am
by timmon
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();

Re: Cannot click Ranorex identified element in html

Posted: Mon Apr 11, 2016 12:13 pm
by odklizec
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?

Re: Cannot click Ranorex identified element in html

Posted: Mon Apr 11, 2016 12:52 pm
by timmon
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

Re: Cannot click Ranorex identified element in html

Posted: Mon Apr 11, 2016 1:02 pm
by odklizec
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.

Re: Cannot click Ranorex identified element in html

Posted: Mon Apr 11, 2016 1:06 pm
by timmon
I'm sorry but I can't provide credentials in here but could I send those in some little bit more secure way?

Re: Cannot click Ranorex identified element in html

Posted: Mon Apr 11, 2016 1:13 pm
by odklizec
Sure. I would suggest to create a temporary credentials and send them via PM (private message).

Re: Cannot click Ranorex identified element in html

Posted: Tue Apr 12, 2016 2:15 pm
by odklizec
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.