Skip to main content

Wait-for-the-Page-to-Load

Command Description

Wait for the currently loading page to finish loading

Command Prototype

iRet = WebBrowser.WaitPage(hWeb,arrElement,iTimeOut,optionArgs)

Parameter Description

ParameterRequiredTypeDefaultDescription
hWebTrueexpressionhWebBrowser handle string using WebBrowser.create or WebBrowser.bind Command Returns
arrElementTruedecorator{}When the page is loaded, it determines whether the specified element exists. The element feature is an array. When a specific element appears, the function will return the index of the found element (starting from 1). If none of the elements appears, wait for at least one element to appear or time out to exit; if the parameter is left blank, no element will be evaluated
iTimeOutTruenumber60000The timeout for the page to be loaded. If it expires, it is determined that the loading fails. The default time is 60000 milliseconds (60 seconds)
bContinueOnErrorNonebooleanNoneSpecify whether the automation should continue to support this field even if the activity is incorrect, it is only supported by the Boolean value (true, false) default value
iDelayAfterNonenumber300Delay time (in milliseconds) after executing the activity is 300 milliseconds
iDelayBeforeNonenumber200The delay time (in milliseconds) before any operations are executed is by default 200 milliseconds

return

iRet,The variable used to save the output of the command.

Demo

/************************************Wait for the page to load************* **************************** 
Command prototype:
WebBrowser.WaitPage(hWeb,arrElement,iTimeOut,optionArgs)
Input parameters:
hWeb--Browser object
bWait--Whether to wait for the command to return after the page is loaded
arrElement--Determine whether the specified element exists
iTimeOut--timeout for waiting for page load
bContinueOnError--whether to continue after error
iDelayAfter-- delay after execution
iDelayBefore--delay before execution
Outgoing reference:
iRet--command return result
*********************************************************************************/
Dim hWeb,iRet
hWeb = WebBrowser.Create("ie","www.baidu.com",30000,{"bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200,"sBrowserPath":"","sStartArgs":""})
TracePrint(hWeb)
hWeb = WebBrowser.BindBrowser("ie",10000,{"bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200})
TracePrint(hWeb)
iRet = WebBrowser.WaitPage(hWeb,{"wnd":[{"cls":"IEFrame","title":"*","app":"iexplore"},{"cls":"Internet Explorer_Server"}],"html":[{"aaname":"热门微博","tag":"SPAN"}]},60000,{"bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200})
TracePrint(iRet)