Micro Focus QTP (UFT) Forums

Full Version: Sendkeys to close an open web browser
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How to activate a web browser and sendkeys for closing it?
i have written the script as follw

Code:
Set WshShell = CreateObject("WScript.Shell")

Browser("name:=Google").Activate
wait(3)
WshShell.SendKeys ("%{F4}")


But it is not working.....
WORNING: no method like 'Activate' for web page

can anybody correct it??

Thanks
This will close the last opened browser.

Code:
Function CloseLastOpenedBrowser()

Dim oDescription
Dim BrowserObjectList
Dim oLatestBrowserIndex

Set oDescription=Description.Create
oDescription("micclass").value="Browser"
Set BrowserObjectList=Desktop.ChildObjects(oDescription)
oLatestBrowserIndex=BrowserObjectList.count-1

Browser("creationtime:="&oLatestBrowserIndex).close

Set oDescription=Nothing
Set BrowserObjectList=Nothing
Print "Close Category Total Report browser pdf"
Reporter.ReportEvent 0, "Browser PDF" , "Report closed successfully"


End Function
Thanks.

it is working perfectly.
But i need to check the functionality of (Alt+F4)
Here i want to use the Key (Alt+F4) to close a web page in internet explorer 7.
Please guide me how to use the 'Sendkeys' method