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 get all the objects count and objects names in webpage using QTP ?

6 Answers  


This is Ajay i have few douts if anybody know pls give me reply. 1. i have opend 2 gmails i am working with 1 gmail i want to close other gmail by usig script. 2.i have 10 links in a page all of them have same properties& names i want to click on 5link by using script. 3.i have one combobox in that i want to see all the citynames in the combobox and i have to check weather hyderabad is present or not. 4. size of objectrepository. 5.what r problems we get during writing the script. 6.is it possible to compare to excel sheets in qtp if possible wht is the script. 7.example for lowlevelrecording

3 Answers   Symantic Space,


Hi All,I am in wierd situation that my laptop is installed with QTP11 and os is xp sp3.The problem is the descriptive programming which i have written is working in other laptops and it is not working in my laptop.it is clicking the link which is above the testbox instead of typing it in textbox below it.It is same with the other working scripts written by another person.

1 Answers  


what is synchronization point, synchronization method, wait property method? with examples.. plz explain this in brief

3 Answers  


is it possible to operate(on/off)the capslock using qtp

2 Answers  






Hi I'm a beginner in QTP. So far I'm ok with Descriptive but stuck while implementing Hybrid Frame work. 1. I have created a Keyword file with .vbs ext set home=description.create home("title").value="Welcome to feests" set reglink=description.create reglink("name").value="register yourrestaurant / take away" set fbusname=description.create fbusname("name").value="business_name" set dispname=description.create dispname("name").value="display_name" set restchkbox=description.create restchkbox("name").value="restaurant" set cuiscate=description.create cuiscate("name").value="cuisine_categery1" set addline1=description.create addline1("name").value="address_line1" set pstcode=description.create pstcode("name").value="address_postcode" set cntry=description.create cntry("name").value="address_country" set mlandno=description.create mlandno("name").value="landline_no" set emailadd=description.create emailadd("name").value="email" 2. I have created an Function Library file as follows Function launch() bro="C:\Program Files\Internet Explorer\iexplore.exe" url="http://www.feests.com/" invokeapplication bro&" "&url Browser(home).page(home).Link(reglink).click End Function Function restregistration(karthik, teja, Ameerpet, UK) Browser(home).page(home).WebEdit(fbusname).set "karthik" Browser(home).page(home).WebEdit(dispname).set "teja" Browser(home).page(home).WebCheckBox(restchkbox).set "ON" Browser(home).page(home).WebList(cuiscate).Select "Indian" Browser(home).page(home).WebEdit(addline1).set "Ameerpet" Browser(home).page(home).WebEdit(pstcode).set "UK" Browser(home).page(home).WebList(cntry).select "United Kingdom" Browser(home).page(home).WebEdit(mlandno).set "023775347" Browser(home).page(home).WebEdit(emailadd).set "email@gmail.com" End Function 3. This is how I have called the keywords and Functions in QTP executefile"C:\Documents and Settings\karthik\Desktop\keywords.vbs" executefile"C:\Documents and Settings\karthik\Desktop\functions.vbs" launch restregistration karthik, teja, Ameerpet, UK, "email@gmail.com" Now the issue is, I'm trying to enter the email ID in WebEdit field. But I dont know what is the mistake I did, if I run the script in QTP it is showing following error Error: Expected identifier Line (2): "executefile"C:\Documents and Settings\karthik\Desktop\functions.vbs"". Can someone help me fix this, please!!?

0 Answers  


what is throw object ?

1 Answers  


What is positive test case and Negative Test case? What is the meaning of Real World Scenario's?

2 Answers   TCS,


hi i have 4 yrs exp in manual and automation testing using QTP i need sample resumes plz can u send this mail id pbre1980@gmail.com

0 Answers  


Explain the check points in QTP?

22 Answers   Gray Matrix, IBM, Microsoft, Prapan Solutions, Zensar,


Excepton Handling?

0 Answers   Wipro,


How to export data present in Datatable to an ".xls" file?

1 Answers   Crea,


Categories