DoubleClick() skipping items in foreach statement

Class library usage, coding and language questions.
kmck
Certified Professional
Certified Professional
Posts: 83
Joined: Fri Jul 12, 2013 2:41 pm

DoubleClick() skipping items in foreach statement

Post by kmck » Wed Oct 30, 2013 2:02 pm

Hello,

I'm trying to use a very simple user code containing a foreach statement iterating through listitems and double clicking on each item.

I've used this in a lot of modules, but this issue seems to have just started up after I upgraded to Ranorex 4.1.2 .

What's happening is that it double clicks on every other item rather than every item. If I do a single click in the foreach statement, each item will get clicked. The referenced list is correct, and I've ensured each item is, in fact, a ListItem. Has anyone else had this issue?

Code: Select all

var userClasses = repo.FrmUsers.PermissionsTab.UserClassesList;

IList<listItem> userClassItems = userClasses.FindCHildren<ListItem>();

foreach(ListItem classItem in UserClassItems)
{
     classItem.DoubleClick();
}

mdgairaud
Posts: 87
Joined: Sun Aug 05, 2012 11:59 am
Location: Bilbao, Spain

Re: DoubleClick() skipping items in foreach statement

Post by mdgairaud » Thu Oct 31, 2013 9:33 am

try to put a pause inside the foreach, Rx takes some time to read the path and do the action. I always put a lot of delays between Rx statements because of this.

Code: Select all

var userClasses = repo.FrmUsers.PermissionsTab.UserClassesList;

IList<listItem> userClassItems = userClasses.FindCHildren<ListItem>();

Ranorex.Delay.Duration(1000);

foreach(ListItem classItem in UserClassItems)
{
     classItem.DoubleClick();
     Ranorex.Delay.Duration(1000);
}

kmck
Certified Professional
Certified Professional
Posts: 83
Joined: Fri Jul 12, 2013 2:41 pm

Re: DoubleClick() skipping items in foreach statement

Post by kmck » Thu Oct 31, 2013 1:04 pm

Hi mdgairaud,

Thanks for your response. I have also tried putting in delays, but it will still skip over every other item, and then when it reaches the end of the list, it starts clicking on items outside of the list the IList references. For instance, it will run through the list items and then start clicking on other parts of the application randomly.

It's very strange, and I'm not sure why classItem.Click() works fine, while classItem.DoubleClick() doesn't.

kmck
Certified Professional
Certified Professional
Posts: 83
Joined: Fri Jul 12, 2013 2:41 pm

Re: DoubleClick() skipping items in foreach statement

Post by kmck » Fri Nov 01, 2013 6:16 pm

Whew, I figured it out. My application removes the item that's double clicked, so it tricks Ranorex into skipping the next one thinking that the item following that item is the one it should double click.

for(Int i = 0; i<userClassItems.Count; i++)
{
userClassItems[0].DoubleClick();
}

The items are removed and I'm no longer pulling my hair out :lol: