CurrentPage$

Web function.

The CurrentPage$ function returns the title of the current Web page.

Usage

Some Web sites have dynamic page titles (the title changes at each display), CurrentPage$ will retrieve the correct page title.

Syntax

page_title$=CurrentPage$()

Return value

page_title$, string. It gives the title of the current Web page as seen by WinTask processing Web pages. So a StartBrowser or a UsePage must be in the script before, or an empty string will be returned.

Remarks

CurrentPage$ returns the current Web page without any synchronization, so the page must have finished to load.

Examples

 

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

'Note that StartBrowser makes the automatic synchronization and waits until the page is loaded.
a$=currentpage$()

msgbox(a$)

Error sub-routine returning the non-expected page loaded after a link has been clicked and the page after that click is not the expected one:

 

sub iferror()
local page$
page$=currentpage$()
'page$ contains the page displayed just before the call to that function.
msgbox(page$)
usepage(page$)
'To come back to a known web page, we click Home in the error Sub
ClickHTMLElement("A[HREF= 'http://www.wintask.c']")

endsub

'Use example on www.wintask.com
startbrowser("ie","www.wintask.com")

UsePage("WinTask - Automation software and Task Scheduler. Macro software with Macro Recorder")

'This clickHtmlelement loads the page which contains the text searched by the next OCR Pause
'ClickHTMLElement("A[INNERTEXT= 'How It Works']")

'This clickhtmlelement loads a page which makes fail the next OCR synchronization.
ClickHTMLElement("A[INNERTEXT= 'Free Downloads']")

ret = UseOCREngine(1)
ret=0
Pause 30 until
TextOCR("on the recording ")
InWindow("IEXPLORE.EXE|Internet Explorer_Server||1",1)
PauseOK
ret=1
PauseFalse
ret=0
EndPause

if ret=0 then
'The pause OCR failed if ret=0, so we call the Error Sub to know which page title is currently displayed	
iferror()
endif