Forum Discussion

mkiewicz's avatar
mkiewicz
Occasional Contributor
8 years ago
Solved

Run Browsers in Parallel

We need to be able to run two browsers in parallel up to a certain point and take a screenshot to test functionality of two users in the same space as how our application would react when  that situa...
  • AlexKaras's avatar
    AlexKaras
    8 years ago

    Hi,

     

    If the browser is at different pages during the test, than it should be no problem to distinguish these two pages just by web address.

    If the address is the same, then:

    -- Page is a logical object provided by TestComplete to support cross-browser testing. Every Page object has complimentary BrowserWindow object that represents actual parent object (container) for the Page one. Because BrowserWindow object represents a window object provided by OS, it has its handle;

    -- It is possible to match Page object to its BrowserWindow container using this code (provided by SmartBear;s Support somewhere in time, VBScript)

    '-----------------------------------------------------------------------------
    
    ' Returns BrowserWindow object that corresponds to the given page object
    ' From: http://smartbear.com/forums/f75/t83264/how-to-match-a-page-object-to-its-browserwindow
    Function BrowserWindowByPageGet(ByRef page)
      Const cProcName = "BrowserWindowByPageGet"
      Dim cProcNameMsgPrefix : cProcNameMsgPrefix = cUnitNameMsgPrefix & cProcName & "(): "
    
      Dim title
      Dim wnd
      Dim strMsg
    
      Set wnd = Utils.CreateStubObject
      If (Not IsNull(page)) Then
        If ("Page" = page.ObjectType) Then
          strMsg = "Waiting for the page to load from the web server..."
          Do Until aqObject.IsSupported(page, "contentDocument")
            Call aqUtils.Delay(500, strMsg)
          Loop
          Do Until aqObject.varDispatch = aqObject.GetVarType(page.contentDocument)
            Call aqUtils.Delay(500, strMsg)
          Loop
          Do Until aqObject.IsSupported(page.contentDocument, "title")
            Call aqUtils.Delay(500, strMsg)
          Loop
    
          title = page.contentDocument.title
          Set wnd = page.Parent.FindChild("WndCaption", title & "*")
          If (Not wnd.Exists) Then
            Set wnd = page.Parent.FindChild("WndCaption", Project.Variables.pvtBaseURL)
          End If
        End If
      End If
      Set BrowserWindowByPageGet = wnd
    End Function
    '-----------------------------------------------------------------------------
    

    -- Assuming that pages are opened one by one, you may

      -- either just keep references to two opened pages in two global variables and use the variable that is needed at the given moment;

      -- or, if you really need to use handle for some reason, you may create a kind of dictionary, keep handle as a key and a reference to the Page object as a corresponding value.