Closing browsers through Descriptive Programming
--------------------------------------------------------------
While Browser("CreationTime:=0").Exist
Browser("CreationTime:=0").Close
Wend
bIndex = 0 'Set Browser index to 0
While Browser("CreationTime:="&bIndex).Exist(1) 'Loop untill the last browser
bTitle = Browser("CreationTime:="&bIndex).GetROProperty("title") 'Get the browser title
If InStr(bTitle,"Google") = 0 And InStr(bTitle,"Yahoo") = 0 And InStr(bTitle,"Gmail") = 0 Then
Browser("CreationTime:="&bIndex).Close 'If the title doesn't contain Google or Gmail or Yahoo, close it
If bIndex <> 0 Then
bIndex = bIndex - 1 'If browser index is more than 0 and a browser is closed, decrease the index value by 1
End If
Else
bIndex = bIndex + 1 'If no browser is closed for certain run, increase the index value by 1
End If
Wend
Through Tool (QTP)
-------------------------
Go to Tools-->Options-->Web
Here you can see an option "Ignore the following browsers" where you can add your required browser details which QTP will ignore during record/run.
Using HWND:
------------------
Dim HWND: HWND = Browser( "title:=Google" ).GetROProperty( "HWND" )
SystemUtil.CloseProcessByHWND HWND
Using Process ID:
----------------------
PID = Browser("title:=Google").GetROProperty("process id")
SystemUtil.CloseProcessByID PID
Source: Internet
No comments:
Post a Comment