UsePage

Web function.

The UsePage function specifies the HTML page used by Web functions.

Usage

UsePage is used to bring to foreground/front the specified Web page so that it may receive the next interactive actions. It includes an automatic synchronization : the next step in the script is processed only when the specified page has been found and ready for receiving actions. Wildcards are supported in page titles by just truncating the unwanted last characters in the page title.

Syntax

UsePage(<page_title>)
or
ret=UsePage(<page_title>)

Parameters

<page_title>, string, Web page title of the Web page to which script actions will be directed. You can use the SPY tool to generate automatically this statement when you want to capture an HTML object on this specified Web page.

WinTask 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 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 makes it active and sends all actions to it. An approaching title is any title starting with the same first character as specified in the UsePage function (case sensitive).

Return value

Ret, numeric return code. When the <page_title> has been found and can be activated, the function returns 0, otherwise use this return code for Error Handling.

List of negative error codes

-1

No browser in use (no previous UsePage or StartBrowser)

-2

No browser having the expected page title has been found

-3

Bad descriptor, invalid syntax

-4

The browser has been lost (for instance because of a Closewindow)

-5

Page with the expected title has not been loaded within the timeout

-8

Specified element not found

-11

Any other error

-404,405

Usual http error codes

-2146697211

 An HTTP error prevents the specified page to load (usually due to a security reason)

 

Remarks

At execution, a UsePage replay forces the script to wait until the specified page is fully loaded, even if a same UsePage line has been executed before. Recording mode does not generate a UsePage line if a new page loads with the same title : to force the synchronization, you can then add manually the same UsePage line which has not been generated automatically.

See also

#UsePageExact

Example

The script below opens the Web site www.wintask.com, uses the main page of the Web site, captures a paragraph and displays its content

 

StartBrowser("IE","www.wintask.com")

UsePage("Macro and Data Extraction with WinTask - the automation software for Windows and internet")
ret = CaptureHTML("LI[CONTENT='Eliminate']", var$)
Msgbox(var$)

CloseBrowser()