Suppose there are 10 browsers opened on desktop. I want to
close all browsers except one browser in QTP. Can any one
give the code for this?

Answers were Sorted based on User's Feedback



Suppose there are 10 browsers opened on desktop. I want to close all browsers except one browser i..

Answer / sharath

you can use descriptives programming concepts.
"CreationTime" is a QTP browser property, which indicates
the order in which browsers were opened.
To close 1st browser --> Browser("CreationTime:=0").Close
2nd browser --> Browser("CreationTime:=1").Close.
you can use a loop to close other 9 browsers..

Is This Answer Correct ?    17 Yes 3 No

Suppose there are 10 browsers opened on desktop. I want to close all browsers except one browser i..

Answer / nihar ranjan sethy

set odesc=description.create
odesc("micclass").value="browser"
set x=desktop.childobjects(odesc)
for i=10 to 2 step-1
x(i).close
next

Is This Answer Correct ?    4 Yes 0 No

Suppose there are 10 browsers opened on desktop. I want to close all browsers except one browser i..

Answer / rico

just made a small correction. Here goes the updated answer



Set browserDesc = Description.Create()
browserDesc(”application version”).Value = “internet
explorer 6"

Set Allbrowsers = DeskTop.ChildObjects(browserDesc)
BrowserCnt = Allbrowsers.Count

For i = 0 To (browserCnt -2)
Allbrowsers(i).Close
Next

Set browserColl = Nothing
Set browserDesc = Nothing

Is This Answer Correct ?    7 Yes 7 No

Suppose there are 10 browsers opened on desktop. I want to close all browsers except one browser i..

Answer / sireesha

If you want to close all browsers except gmail browser then you will follow this code.
set ObjDesk = Description.Creation
ObjDesk("micclass").Value="Browser"
set ObjDec =Desktop.ChildObjects(ObjDesk)

BroCount=ObjDec.Count

msgbox BroCount

if BroCount >0 then

for i=BroCount-1 to 0 step-1
if Instr(1,Browser("CreationTime=&i").GetRoproperty("name"),"gmail")=0 then

Browser("CreationTime:=&i").Close
End If
Next
End If

Is This Answer Correct ?    2 Yes 2 No

Suppose there are 10 browsers opened on desktop. I want to close all browsers except one browser i..

Answer / vijay

While Browser("creationtime=0").exist(0)
Browser("creationtime=0").close
wend

Is This Answer Correct ?    1 Yes 1 No

Suppose there are 10 browsers opened on desktop. I want to close all browsers except one browser i..

Answer / shankar

set brow=description.create
brow("micclass").value="browser"
set brows=Desctop.childobjects(brow)
for i=0 to brows.counts-1
browser(brow).close

please reffer this and if it is wrong give me clarification.

Is This Answer Correct ?    0 Yes 1 No

Suppose there are 10 browsers opened on desktop. I want to close all browsers except one browser i..

Answer / rico

Assuming all 10 browsers are IE6

Set browserDesc = Description.Create()
browserDesc(”application version”).Value = “internet
explorer 6″

Set Allbrowsers = DeskTop.ChildObjects(browserDesc)
BrowserCnt = Allbrowsers.Count

For i = 0 To (browserCnt -2)
Allbrowsers(i).Close
Next

Set browserColl = Nothing
Set browserDesc = Nothing

Is This Answer Correct ?    4 Yes 8 No

Post New Answer

More QTP Interview Questions

How to carry out bit map check points in QTP

0 Answers   kenexa,


How good are you in writing VBscript code for your application? Can you completely write VBscrit for your project with out using recording mode in QTP?

3 Answers   CTS,


How can we export test results to an excel sheet in QTP??? Can any one provide sample coding for this?????

6 Answers   TCS,


How to make arguments optional in a function?

1 Answers   IBM,


When u ll use Record Button in QTP?Is VB script is Mandatory in QTP? What is Meaning of Frame("v1")?

1 Answers   TCS,






Can someone tel additonal features which has been included under QTP 9.0 which is not there in 8.2 version?

1 Answers  


How To clear the AutoComplete?

1 Answers  


WHAT IS THE FUNCTION (HOW TO DO) THE BATCH TESTING IN TEST DIRECTOR USING MANUAL TESTING PROCEDURE?

1 Answers   CTS,


Hello, Is there any way to send the test results in html format (or any other) by email using outlook after the test run ends? thank you in advance

0 Answers  


Explain how you can find length of array in qtp?

0 Answers  


I want to execute 1st row of the local sheet and 3rd row of the global sheet parellely. write script to execute

2 Answers   IBM,


In 1st screen,if v enter a/c no. in one field, the information of the subscriber will be displayed. The details should be displayed only in screen 3(NOTE:details should not display in screen 2).How can v do using QTP.

2 Answers   BirlaSoft, TCS,


Categories