Home > Language Reference > Web Functions > UsePage

UsePage

The UsePage function waits for the specified page to load before executing next steps.

Usage

Used to be sure that the page is ready before using elements displayed on the web page. Recording mode generates automatically the UsePage statements unless the pages have the exact same title. Wildcards are supported in page titles by just truncating the unwanted last characters in the page title.

Video: The UsePage WinTask x64 function waits until the page specified by UsePage is fully loaded before executing next line in the WinTask x64 script. This tutorial explains how Recording mode generates the UsePage lines and shows when some additional UsePage lines must be added or modified.

Syntax

ret=UsePage(<page_title>)

Parameters

<page_title>, string, title of the web page to which script actions will be directed after it has finished to load.

Return value

Ret, optional numeric return value. UsePage function waits for the specified page to load within the timeout period  (30 seconds by default or the #ActionTimeout value). If the page is loaded within this timeout period, the function returns 0. If the page cannot be loaded, the return value is a nonzero negative value (see Web Functions Error Codes).

Remarks

At execution, a UsePage call forces the script to wait until the specified page has finished to load, even if a same UsePage statement has been executed before. Recording mode does not generate a UsePage statement if a new page loads with the same title : to force the wait, you can then add manually in the script the same UsePage statement.

WinTask x64 will try to find the Web page defined by UsePage for a period of time defined by the system variable #ActionTimeout (default value is 30 seconds). Once the page is found, WinTask x64 makes it active and sends all Web actions to it. If #UsePageExact is not set to 1, if a page with an approaching title is found, WinTask x64 makes it active and sends all actions to it (default behavior). An approaching title is any title starting with the same first character as specified in the UsePage function (case sensitive).

See also

#UsePageExact
Web Synchronization
#PageSynchroLevel

Examples

'Use Recording mode to launch URL ww.wintask.com/demos using Internet Explorer
'Wait for page "WinTask Demonstration Pages" to load and click the "Multiple pages iteration" link
StartBrowser("IE","www.wintask.com/demos")
UsePage("WinTask Demonstration Pages")
ClickHTMLElement("A[INNERTEXT= 'Multiple pages itera']")
'Wait until the new page titled Page Iteration 1 is loaded
UsePage("Page Iteration 1")
    ClickHTMLElement("A[INNERTEXT= '2']")
CloseBrowser()

'Use Recording mode to launch URL ww.wintask.com/demos using Firefox
'Wait for page "WinTask Demonstration Pages" to load and click the "Multiple pages iteration" link
StartBrowser("FF","www.wintask.com/demos")
UsePage("WinTask Demonstration Pages")
ClickHTMLElement("A[INNERTEXT= 'Multiple pages itera']")
'Wait until the new page titled Page Iteration 1 is loaded
UsePage("Page Iteration 1")
    ClickHTMLElement("A[INNERTEXT= '2']")
CloseBrowser()


'Use Recording mode to launch URL ww.wintask.com/demos using Chrome
'Wait for page "WinTask Demonstration Pages" to load and click the "Multiple pages iteration" link
StartBrowser("CH","www.wintask.com/demos")
UsePage("WinTask Demonstration Pages")
ClickHTMLElement("A[INNERTEXT= 'Multiple pages itera']")
'Wait until the new page titled Page Iteration 1 is loaded
UsePage("Page Iteration 1")
   ClickHTMLElement("A[INNERTEXT= '2']")
CloseBrowser()