Forum Discussion

kaiiii's avatar
kaiiii
Regular Contributor
5 years ago

Unable to execute script on CBT

In Crossbrowser testing when we are executing our script on (window10  and firefox65 (64 bit))

facing an error "Another browser is used." 

for full details kindly check the attachment.

Also check below code, here in parameter BrowserName have chrome as per my test data and in CBT I am executing on firefox, I think this the problem.

 

Sub OpenBrowserWithURL (BrowserName,URL)
Dim firefox,InternetExplorer,Chrome,Edge
If (BrowserName="Firefox")Then
Browsers.Item("firefox").RunOptions = "-P ""Tester"""
Sys.Browser.BrowserWindow(0).Maximize
ElseIf (BrowserName="InternetExplorer")Then
Browsers.Item("iexplore", "11", Browsers.pX64).Run URL
Sys.Browser.BrowserWindow(0).Maximize
ElseIf (BrowserName="Edge")Then
Browsers.Item(btEdge).Navigate(URL)
Sys.Browser.BrowserWindow(0).Maximize
ElseIf (BrowserName="Chrome")Then
Browsers.Item(btChrome).Navigate(URL)
Sys.Browser("chrome").BrowserWindow(0).Maximize
Log.Checkpoint("Browser Name: "&BrowserName)
Log.Checkpoint("URL: "&URL)
End If
Browsers.Refresh
End Sub

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    And, as a side note...

    Your code and my comments in italics:

    If (BrowserName="Firefox")Then
      Browsers.Item("firefox").RunOptions = "-P ""Tester""" ' This does not start browser
      Sys.Browser.BrowserWindow(0).Maximize ' This code will use any running browser (if any) because no browser was started explicitly
    ElseIf (BrowserName="InternetExplorer")Then
      Browsers.Item("iexplore", "11", Browsers.pX64).Run URL
      Sys.Browser.BrowserWindow(0).Maximize ' same note as for FireFox
    ElseIf (BrowserName="Edge")Then
      Browsers.Item(btEdge).Navigate(URL) ' as per documentation, .Navigate() does not start the browser, so I'm doubting that this line will work
      Sys.Browser.BrowserWindow(0).Maximize ' again, this does not guarantee that expected browser will be affected
    ElseIf (BrowserName="Chrome")Then
      Browsers.Item(btChrome).Navigate(URL)
      Sys.Browser("chrome").BrowserWindow(0).Maximize
      Log.Checkpoint("Browser Name: "&BrowserName) ' by definition, passed checkpoint means succeeded comparison/expected behavior. There is no verification either here or above. What is the reason to log succeeded checkpoint to test log?
      Log.Checkpoint("URL: "&URL)
    End If
    Browsers.Refresh ' what is the reason to refresh the list of existing browsers if none of them was (re)installed?

     

    • kaiiii's avatar
      kaiiii
      Regular Contributor

      Hi AlexKaras ,

      Thanks.. I got your point but I Stuck here as I do'nt know what should do exactly in the function.

      Can you please tell me a bit the right way to start browser function. so it will execute successfully on CBT and normal execution.

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        kaiiii :

        Hi,

         

        OK, got it. :)

         

        Can you please tell me [...]

        I wish I could... Really...

        I tried CBT only when it was initially introduced in TestComplete several years ago. For TestComplete CBT supported only desktops with desktop browsers which I was not really interested at as I was looking for mobiles support. Thus I did not renew my trial CBT account. With the scalable web testing support introduced in TC 14.4 Beta I am thinking to try CBT one more time but still not sure as I think that scalable web still misses some important functionality which, I believe, will be implemented in version 14.5.

         

        So I would recommend to investigate this yourself or ask CBT support. (And I will really appreciate it if you update this thread with the results.)

        Right now I am tending to join Robert's explanation that with CBT you are getting only the browser that you requested. I am not sure whether or not it is started by default. Also I am not sure how to check if the test is running in the CBT environment or not. In the worst case you should be able to set some flag (Project Variable?) before starting tests in CBT.

        I hope that you should be able to use Browsers object to find available browsers and, in combination with the above flag, start a proper browser.

         

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Each CBT environment is configured specifically for a combination of operating system and browser.  Running a "chrome" test on a "firefox" environment is not supported.  It won't work. 

    • kaiiii's avatar
      kaiiii
      Regular Contributor

      tristaanogre 

      Exactly.. but this is the problem as we have to execute our script some times seprately and sometimes on CBT.

      In that condition how can I execute my script on CBT.

      Should I change browser in my test data according queue test items in CBT ?

      What is the solution fo that. I am still looking for an answer.

       

       

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        You need to make sure you only attach Chrome tests to chrome environments and Firefox tests to Firefox environments.  You can also write your code better to run only the browser that's on the environment.  

        This comes down to smarter code...  only running what you need to run, when you run it, and on which environment you run it.  In my experimentation with CBT, you explicitly attach tests to an environment and run them.  So, you should design your tests for the environment and run only those on those environments.