Click on each element inside an Ilist

Class library usage, coding and language questions.
Hermch
Posts: 40
Joined: Thu May 26, 2011 7:17 am
Location: Germany

Click on each element inside an Ilist

Post by Hermch » Wed May 16, 2012 10:18 am

Hi,

I've got the following code which first moves to each element inside of an Ilist and after that should click each element from the Ilist:

Code: Select all

'Creates a list of elements which are clicked one after the other
        	Dim ElementList As IList (Of Ranorex.ATag) = repo.WebDocumentBDT_BaseLine.Lower_ButtonLine.Self.FindDescendants (Of Ranorex.ATag) ()
        	
        	Report.Info("Number of objects: " & ElementList.Count.ToString)
        	
        	For Each Element As Ranorex.ATag In ElementList
        	
        		'Moves to each element in the list and reports the name of the element
        		Element.EnsureVisible()
        		Mouse.MoveTo(Element)
        		Report.Info(Element.InnerText)
        		
        		'Clicks on each element and reports the name of the element
        		Element.EnsureVisible()
        		Element.PerformClick
        		Report.Info(Element.InnerText)
        		
        		Report.Info("Button " & Element.InnerText & " exists")
The cursor moves to each element successfully.
But after clicking on the first element in the list, the cursor moves to the upper left corner of the GUI and does not click the other elements in the list.

Ranorex Report says:

Time Level Category Message
00:04.817 Info User Jump to itemNumber of objects: 3
00:05.441 Info User Jump to itemLibrary
00:05.738 Info User Jump to itemLibrary
00:05.888 Info User Jump to itemButton Library exists
00:06.184 Warn Automation Jump to itemView HelpCould not get a valid screen rectangle from element '{ATag:}', since the element is no longer valid.
00:06.668 Info User Jump to item(null)
00:06.948 Info User Jump to item(null)
00:07.089 Info User Jump to itemButton exists
00:07.338 Warn Automation Jump to itemView HelpCould not get a valid screen rectangle from element '{ATag:}', since the element is no longer valid.
00:07.806 Info User Jump to item(null)
00:08.087 Info User Jump to item(null)
00:08.212 Info User Jump to itemButton exists


How can I manage, that the elements are clicked on one after the other?
A delay after clicking the first element does not help. Although the elements are visible, ranorex does not manage to click on them.

Hermch
Posts: 40
Joined: Thu May 26, 2011 7:17 am
Location: Germany

Re: Click on each element inside an Ilist

Post by Hermch » Wed May 16, 2012 11:51 am

I modified the code and added a Do Loop with a delay inside:

Code: Select all

'Creates a list of elements which are clicked one after the other
        	Dim ElementList As IList (Of Ranorex.ATag) = repo.WebDocumentBDT_BaseLine.Lower_ButtonLine.Self.FindDescendants (Of Ranorex.ATag) ()
        	
        	Report.Info("Number of objects: " & ElementList.Count.ToString)
        	
        		For Each Element As Ranorex.ATag In ElementList
        	
        		'Moves to each element in the list and reports the name of the element
        		Element.EnsureVisible()
        		Mouse.MoveTo(Element)
        		Report.Info(Element.InnerText)
        		
        		'Clicks on each element and reports the name of the element
        			
        		Element.EnsureVisible()
        		Element.Click()
        		Do
        			'Delay.Seconds(1)
        			report.Info(element.InnerText)
        			delay.Seconds(1)
        			
        		Loop While Element.Visible = False        	
	
        		Element.Click()
        		Report.Info(Element.InnerText)
        		
        		
        		Report.Info("Button " & Element.InnerText & " exists")
        		
        	Next
Result is, that the loop can not be left. So the "element" is not visible anymore for ranorex?
Why? On the GUI I can see it.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Click on each element inside an Ilist

Post by Support Team » Fri May 18, 2012 3:09 pm

Hi,
Automation Jump to itemView HelpCould not get a valid screen rectangle from element '{ATag:}', since the element is no longer valid.
The warning stated that the screen rectangle of the element is no longer valid, so could it be that the element is disappeared?
Maybe you have to click on the element which includes the ATags before you click on them?
Please also send or post us a Ranorex Snapshot file of the specific elements, or even better can we get access to your page? You can upload the file here, or you can send it to [email protected].
Following link will show you how to generate a snapshot file.

Regards,
Markus
Ranorex Support Team
.
Image