How To Close All IE Browsers Except ALM
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2014
07:48 AM
06-25-2014
07:48 AM
How To Close All IE Browsers Except ALM
How To Close All IE Browsers Except IE browser in which ALM or QC is open .?
Solved! Go to Solution.
10 REPLIES 10
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2014
09:11 PM
06-25-2014
09:11 PM
In testcomplete using the object browser, check what is different in each IE opened, maybe the Page url is different or something...
After that just write a script or a bat file that closes every IE except the one with the property you want.
After that just write a script or a bat file that closes every IE except the one with the property you want.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2014
06:05 AM
06-26-2014
06:05 AM
Its not that easy as you have explained .
Do you have a code that returns the URL of each open IE browser Session ?
Even if we take a count of Open IE browesers ? how will you know the URL of each ?
i dont see any Such property in test complete .
Do you have a code that returns the URL of each open IE browser Session ?
Even if we take a count of Open IE browesers ? how will you know the URL of each ?
i dont see any Such property in test complete .
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2014
08:17 AM
06-26-2014
08:17 AM
I was bored so wrote this function for you...
Didn't fully test it or anything so you may modify as needed...enjoy...
''-Praise the sun and Give Kudos.''
Didn't fully test it or anything so you may modify as needed...enjoy...
function main(){
/*
JScript example
this will close all explorer pages that do not contain google or yahoo in their page name
*/
closeIEPages('iexplore',['google','yahoo']);
}
function closeIEPages(myBrowser,exclusionArray){
if (!Sys.WaitBrowser(myBrowser).Exists){
return;
}
var browserArray = VBArray(Sys.FindAll('Name','*' + myBrowser + '*',1,true)).toArray();
for (var browser = 0;browser < browserArray.length;browser++){
var objectArray = VBArray(browserArray[browser].FindAll(['Name'],['*Page*'],1,true)).toArray();
for (var object = 0;object < objectArray.length;object++){
var excludeTab = false;
for (var exclusion = 0;exclusion < exclusionArray.length;exclusion++){
if (objectArray[object].Name.indexOf(exclusionArray[exclusion]) != -1){
excludeTab = true;
break;
}
}
if (!excludeTab && objectArray[object].Exists){
objectArray[object].Close();
}
}
}
}
''-Praise the sun and Give Kudos.''
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2014
08:06 PM
06-26-2014
08:06 PM
@Ryan Moran "I was bored so wrote this function for you...
" AHAHAHAH, epic!
See @Sumit Kumar, simple as I told you 😉
" AHAHAHAH, epic!
See @Sumit Kumar, simple as I told you 😉
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2014
02:35 AM
06-30-2014
02:35 AM
The Reson why i say its not simple is :
1. it has to close tabs if present in the open IE sessions .
2. sometimes when you Already have any broser session is open and then you invoke the tool it recognises it as window object .
3. The code given above is in javascript and i only use vbscript in my project .
4. i have wriiten a nice code in vbscript long back , it works fine in QTP , but when i tried to run it in test complete it dosnt work .
5. I am aware that there is difference in syntax of passing the Description of the object in qtp and test complete and i have changed that too .
6.but still dosn`t work as Desstop.childobjects in qtp gives you all childobject filter by all IE sessions , but no such method avalioble in tc ...
'==================Original QTP Code==========================
'Function Close_AllBrowser()
'Set oBrowser = Description.Create
'oBrowser("micclass").Value = "Window"
'oBrowser("regexpwndtitle").Value = ".*Internet Explorer.*"
'
'Set oDialog = Description.Create
'oDialog("micclass").Value = "Dialog"
'oDialog("text").Value = "Internet Explorer"
'oDialog("is owned window").Value = "True"
'oDialog("is child window").Value = "False"
'
'
' Set oBrowserList = Desktop.ChildObjects(oBrowser)
'
' Select Case oBrowserList.count
'
' Case 0
' Case 1
' If Instr(oBrowserList(0).GetROProperty("text"), "Application Lifecycle Management") = 0 Then
' oBrowserList(0).Close
' wait(1)
' If oBrowserList(0).Dialog(oDialog).Exist(0) then
' oBrowserList(0).Dialog(oDialog).WinCheckBox("text:=&Always close all tabs", "nativeclass:=Button").Set "ON"
' oBrowserList(0).Dialog(oDialog).WinButton("regexpwndtitle:=Close all &tabs", "text:=Close all &tabs").Click
' End if
' End if
'
' Case Else
' For index = 0 to oBrowserList.count-1
' If Instr(oBrowserList(index).GetROProperty("text"), "Application Lifecycle Management") = 0 Then
' oBrowserList(index).Close
' wait(1)
' If oBrowserList(index).Dialog(oDialog).Exist(0) then
' oBrowserList(index).Dialog(oDialog).WinCheckBox("text:=&Always close all tabs", "nativeclass:=Button").Set "ON"
' oBrowserList(index).Dialog(oDialog).WinButton("regexpwndtitle:=Close all &tabs", "text:=Close all &tabs").Click
' End if
' End if
' Next
'
' End Select
'
' Set oBrowser =Nothing
'
' Set oDialog = Nothing
'End Function
'==============================================================
1. it has to close tabs if present in the open IE sessions .
2. sometimes when you Already have any broser session is open and then you invoke the tool it recognises it as window object .
3. The code given above is in javascript and i only use vbscript in my project .
4. i have wriiten a nice code in vbscript long back , it works fine in QTP , but when i tried to run it in test complete it dosnt work .
5. I am aware that there is difference in syntax of passing the Description of the object in qtp and test complete and i have changed that too .
6.but still dosn`t work as Desstop.childobjects in qtp gives you all childobject filter by all IE sessions , but no such method avalioble in tc ...
'==================Original QTP Code==========================
'Function Close_AllBrowser()
'Set oBrowser = Description.Create
'oBrowser("micclass").Value = "Window"
'oBrowser("regexpwndtitle").Value = ".*Internet Explorer.*"
'
'Set oDialog = Description.Create
'oDialog("micclass").Value = "Dialog"
'oDialog("text").Value = "Internet Explorer"
'oDialog("is owned window").Value = "True"
'oDialog("is child window").Value = "False"
'
'
' Set oBrowserList = Desktop.ChildObjects(oBrowser)
'
' Select Case oBrowserList.count
'
' Case 0
' Case 1
' If Instr(oBrowserList(0).GetROProperty("text"), "Application Lifecycle Management") = 0 Then
' oBrowserList(0).Close
' wait(1)
' If oBrowserList(0).Dialog(oDialog).Exist(0) then
' oBrowserList(0).Dialog(oDialog).WinCheckBox("text:=&Always close all tabs", "nativeclass:=Button").Set "ON"
' oBrowserList(0).Dialog(oDialog).WinButton("regexpwndtitle:=Close all &tabs", "text:=Close all &tabs").Click
' End if
' End if
'
' Case Else
' For index = 0 to oBrowserList.count-1
' If Instr(oBrowserList(index).GetROProperty("text"), "Application Lifecycle Management") = 0 Then
' oBrowserList(index).Close
' wait(1)
' If oBrowserList(index).Dialog(oDialog).Exist(0) then
' oBrowserList(index).Dialog(oDialog).WinCheckBox("text:=&Always close all tabs", "nativeclass:=Button").Set "ON"
' oBrowserList(index).Dialog(oDialog).WinButton("regexpwndtitle:=Close all &tabs", "text:=Close all &tabs").Click
' End if
' End if
' Next
'
' End Select
'
' Set oBrowser =Nothing
'
' Set oDialog = Nothing
'End Function
'==============================================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2014
05:04 AM
07-24-2014
05:04 AM
Anyone has a working code for this in VBscript ?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2014
06:51 PM
07-29-2014
06:51 PM
Hi Sumit,
Will the following code work for you?
Function Close_AllBrowser
Dim pages
pages = Sys.Browser("iexplore").FindAllChildren("ObjectType", "Page", 2)
For i=0 to UBound(pages)
If aqString.Find(pages(i).LocationName, "Application Lifecycle Management") = -1 Then
pages(i).Close()
End If
Next
End Function
The code checks all pages opened in IE and closes all except the one where Application Lifecycle Management is specified in the title.
Will the following code work for you?
Function Close_AllBrowser
Dim pages
pages = Sys.Browser("iexplore").FindAllChildren("ObjectType", "Page", 2)
For i=0 to UBound(pages)
If aqString.Find(pages(i).LocationName, "Application Lifecycle Management") = -1 Then
pages(i).Close()
End If
Next
End Function
The code checks all pages opened in IE and closes all except the one where Application Lifecycle Management is specified in the title.
---------
Tanya Yatskovskaya
SmartBear Community and Education Manager
Tanya Yatskovskaya
SmartBear Community and Education Manager
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2014
09:06 AM
07-31-2014
09:06 AM
Hi Tanya ,
Thanks for your kind help .
yes it is working fine .
Sumit
Thanks for your kind help .
yes it is working fine .
Sumit
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2015
04:15 PM
10-20-2015
04:15 PM
I tried using the above said code, but its throwing me error (apologies, new to QTP, still learning stage)
Object requied: 'Sys'
can someone please help me
Thanks in advance
