Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to find more than one application(AUT) instances are opened.
#1
Solved: 10 Years, 8 Months, 3 Weeks ago
Hi,

During test batch execution the application is not closed,then it remains opened & second instance of the application invoked. Therefore multiple instances may be opened & batch execution fails.

Is there any way in QTP to find the total no. of "Application Under Test" instances are opened?

I know how to close the multiple instances. Use following command for it.
SystemUtil.CloseProcessByName("Notepad.exe")

Thanks in advance.
Dinesh
Reply
#2
Solved: 10 Years, 8 Months, 3 Weeks ago
Hi,

If your application is web based application:
Code:
OnErrorResumeNext
browsercount=0
For temp=1 to 100000 step 1
intbrowser=Browser("xxxxxxxxxxxxx").GetRoProperty("Creation time")
     If len(intbrowser)>=1) Then
          browsercount=browsercount+1
     End If
     If (len(intbrowser)=0) Then
        Exit For
     End If
Next
After executing this script finally you would get the instances i.e browsercount.

Please let me know for further clarification.
Reply
#3
Solved: 10 Years, 8 Months, 3 Weeks ago
Try this:

Code:
Public Function RunBrowser
   Set oBrowser = Description.Create
    oBrowser("micclass").Value = "Browser"

    Set oPage = Description.Create
    oPage("micclass").Value = "Page"

'Get all browsers
    Set allBrowser = Desktop.ChildObjects(oBrowser)

    Dim i, iCount
    iCount = allBrowser.Count - 1

        For i = 0 To iCount
            'Get the page object from the browser
            Set oPg = allBrowser(i).ChildObjects(oPage)(0)
            'Get the URL of the
            If  InStr (oPg.GetROProperty("URL"), "http://yahoo.com") > 0 then  
            'Close the browser
            allBrowser(i).Close
        End If
        Next
    SystemUtil.Run "iexplore.exe", "http://yahoo.com"
End Function

The function will check if in any browser exists the URL on which you are working(if it was not being closed), and will close it, after that will run again the browser with URL you need to be run.

To run your browser, call the method within first action as next:
Code:
'calling the RunBrowser function
RunBrowser

or, you can remove the "SystemUtil.Run "iexplore.exe", "http://yahoo.com"
line from the function and rename the function for e.g. as CloseAllMyURLs, and call it at the end of all your tests - it will check if your browser with your URL is closed:
Code:
'calling the CloseAllMyURLs function
CloseAllMyURLs


OR you can try this method at the end of each test:

Code:
Public Function CloseBrowser
'closing the browser
        If Browser("URL:=http://yahoo.com.*")).Exist Then
            Browser("URL:=http://yahoo.com.*")).Close
        End IF        
End Function
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Smile find out of spelling error in Web application deveshbhatt29 1 2,068 01-10-2014, 05:10 PM
Last Post: Maheep_bhambri
  Unable to send an email from Outlook which is already opened as draft attiliv 0 2,139 03-24-2013, 11:14 AM
Last Post: attiliv
  Download Files from AUT using QTP script qtptest 2 6,431 10-27-2012, 10:21 AM
Last Post: qtptest
  How to identify the object reference to the existing(already opened) Excel sheet yogeesh 1 9,765 09-26-2012, 07:00 PM
Last Post: krr
  how to disable a popup window opened during clicking links of a webpage sanjeebpatel 2 2,857 12-28-2009, 11:40 AM
Last Post: Saket

Forum Jump:


Users browsing this thread: 1 Guest(s)