Page 1 of 1

Click fails if performed programmatically

Posted: Mon Apr 25, 2016 12:19 pm
by van9
hi,

I have a simple structure html structure
<div>
<a>item1</a>
<a>item2</a>
<a>item3</a>
...
...
...
...
<div>

I would like to dynamically click on each aTag so have used user code

Ranorex.DivTag levelbefore = "/dom[@domain='localhost']//div[#'ctl00_tvNavigationn0Nodes']";
//created an adapter

IList<ATag> items = levelbefore.FindDescendants<ATag>();
//called finddescendants

for(int i=0; i<items.Count; i++)
{
//items.MoveTo();
items.Click();
}

The issue is that when the program is run the first click of item1 is successful, and it goes for a toss and clicks somewhere random.
But the same issue is not observed with Moveto() function.
Please let me know what might have gone wrong.

Re: Click fails if performed programmatically

Posted: Mon Apr 25, 2016 3:58 pm
by odklizec
Hi.

I would suggest to add EnsureVisible() before the click action, like this:

Code: Select all

items[i].EnsureVisible()
items[i].Click();
This should make sure the clicked item is visible and ready for click.

Eventually, it may help to split the action into separate MoveTo and Click actions...

Code: Select all

items[i].MoveTo();
items[i].Click();
Mouse Click actually does MoveTo & Click. But in some cases (typically on VMs or remote systems), it's better to split the action into two actions.

Finally, you may try to use PerformClick() method, which does mouse click without moving the mouse...

Code: Select all

items[i].PerformClick();

Re: Click fails if performed programmatically

Posted: Tue Apr 26, 2016 4:50 am
by van9
Hi,

Thanks for the prompt reply.
I have tried by using EnsureVisible() and performClick() and all the combinations but the problem still continue to exist.

Is it because Click() function requires a co-ordinate. Because when we manually record using Ranorex studio it gives a co-ordinate. But I wanted something like an automatic clicking of the elements no matter how many items are there.

The error I am getting is :
"00:08.271 Warn Automation

Could not get a valid element rectangle from '{ATag:ctl00_tvNavigationt2}', since the element is no longer valid. "

Ranorex version: 5.3.1
OS: Windows 7 Enterprise

Re: App get crashed while tap on element in iOS Instrumented app

Posted: Tue Apr 26, 2016 6:12 am
by odklizec
Hi,

Could you please post a sample HTML code which we can try? Or at least the Ranorex Snapshot? But in this particular case, working HTML code would be much more helpful.

Are the atags a part of combo box, a tree list or expanding menu container? If so, then you must most probably expand the container before each click?

Also, what exactly do the clicked atags? If they open another page, then this is a most probable reason why they are not clickable? Once the atag is clicked, it does something, that invalidates the original page with atags and so they cannot be clicked. I think it has nothing to do with coordinates?