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

Explain about opening notepad in QTP and writing of test result in notepad?

4 Answers  


What is deference between normal QTP testing and descriptive programming?

4 Answers   Polaris,


I am having major problems with some DB Table Checkpoints I add to my script. I 35 web based applications recorded and each has DB Table Checkpoints insert but only 1 script isn't recognizing the DB Table Checkpoints for some reason. I've checked the DB connections and the info in the Library Functions and still only this one script out of 35 doesn't recognize the DB Table Checkpoints. Can someone please help me figure out why only this one script out of 35 that's hitting the same database is having a problem.

0 Answers  


There are 10 rows in the datatable. How can we fetch 2 rows and then skip 3rd row. After that, pick 4th & 5th row and skip 6th row. Please share code

0 Answers  


if you run one test script in internetexplorer the same test you run in mozilla ffirefox is it possible or not how is it.

1 Answers   Satyam,


how can i parameterize a login page by using database parameterization i fetch the username and password from database and put this on login page and click on ok button. so how can we write script for that code please let me know asap thanks

4 Answers   iCreate,


Diff b/n image n bitmap checkpoints?

2 Answers   iGate,


requirement is for combo box your expected value is str= "Denver.Frankfurt.London.Los Angeles.Paris.Portland.San Francisco.Seattle.Sydney.Zurich" you must get the text in combo box and need to compare them how

0 Answers   FIS,


What is the difference between Call to Action and Copy Action.?

2 Answers  


What is the differnce between action & script

2 Answers   Lehman Brothers,


What are the Features & Benefits of Quick Test Pro ?

1 Answers   Crea,


how do you do database testing in qtp

5 Answers   NIIT,


Categories