in my test, i need to surf through site, using hyperlink, which name (and the caption) is ‘next’. I added it from my application, and used a ‘click’ method. It is working only for the first time, so browser navigated to the second page and had stucked there. My code is below:
Do
Set msgList = Browser("Incoming — Gmail").Page("ВIncoming — Gmail").ChildObjects(msgDesc)
msgCount = msgCount + msgList.Count()
Reporter.ReportEvent micPass, "MessagesCount", "Messages: " & msgCount
'MsgBox msgList.Count() ' in a purpose of debugging
Loop While SurfNextPage(Browser("Incoming — Gmail").Page("Deliver successfull"))
'Function surfs to the next page, if it possible
' currPage -- current page
'Return: TRUE, if link to the next page is available, otherwise ELSE
Function SurfNextPage(currPage)
Dim bResult
Set hlDesc = Description.Create
hlDesc("name").Value = "next"
Set hlList = currPage.ChildObjects(hlDesc)
For i = 0 to (hlList.Count()-1)
Set urlNextMail = hlList(i) 'there would be the only element in list
Next
bResult = urlNextMail.Exist
If bResult Then
urlNextMail.Click 'surfs to the next page
End If
SurfNextPage = bResult
End Function
The web-page has a difficult structure — a lot of DIV and Java, so i can’t say exactly to which frame or table this link belongs, but there are no another links with the same name.
After some back and forth in the comments it appears that the
nextlink does exist on the last page but clicking it does nothing.You should modify the description you’re using in order to identify the link so that it only matches links that move to the next page and not the link that is invisible (but there) on the last page.
Original answer:
Since you’re always using the same page to call
SurfNextPagethen this method should work (assuming there is a"next"link in the object repository under said page).If you want to use different pages then you should use descriptive programming, i.e. not use an object from the repository, instead use something like this
currPage.Link("text:=next")this will look for a link with"next"as its text property.Another thing that may be going wrong is that an object is identified before a navigation and then the navigation invalidates the object. If this is the case you should use the
RefreshObjectmethod (as explained in the documentation).If none of these suggestions help please provide more information on what exactly is getting “stucked”