Try this:
The function will check if in any browser exists the URL on which you are working(if it was not being closed), and will close it, after that will run again the browser with URL you need to be run.
To run your browser, call the method within first action as next:
or, you can remove the "SystemUtil.Run "iexplore.exe", "http://yahoo.com"
line from the function and rename the function for e.g. as CloseAllMyURLs, and call it at the end of all your tests - it will check if your browser with your URL is closed:
OR you can try this method at the end of each test:
Code:
Public Function RunBrowser
Set oBrowser = Description.Create
oBrowser("micclass").Value = "Browser"
Set oPage = Description.Create
oPage("micclass").Value = "Page"
'Get all browsers
Set allBrowser = Desktop.ChildObjects(oBrowser)
Dim i, iCount
iCount = allBrowser.Count - 1
For i = 0 To iCount
'Get the page object from the browser
Set oPg = allBrowser(i).ChildObjects(oPage)(0)
'Get the URL of the
If InStr (oPg.GetROProperty("URL"), "http://yahoo.com") > 0 then
'Close the browser
allBrowser(i).Close
End If
Next
SystemUtil.Run "iexplore.exe", "http://yahoo.com"
End Function
The function will check if in any browser exists the URL on which you are working(if it was not being closed), and will close it, after that will run again the browser with URL you need to be run.
To run your browser, call the method within first action as next:
Code:
'calling the RunBrowser function
RunBrowser
or, you can remove the "SystemUtil.Run "iexplore.exe", "http://yahoo.com"
line from the function and rename the function for e.g. as CloseAllMyURLs, and call it at the end of all your tests - it will check if your browser with your URL is closed:
Code:
'calling the CloseAllMyURLs function
CloseAllMyURLs
OR you can try this method at the end of each test:
Code:
Public Function CloseBrowser
'closing the browser
If Browser("URL:=http://yahoo.com.*")).Exist Then
Browser("URL:=http://yahoo.com.*")).Close
End IF
End Function