Forum Discussion

S_Seydel's avatar
S_Seydel
Contributor
7 years ago

Browser.Page(mypage).close() in edge

Hi,

 

I experience a strange behaviour in edge executing the following code:

 

   function cleanUpWorld()
   {
      var testedBrowser = ProjectSuite.Variables.testedBrowser;
      var cleanupScriptUrl = ProjectSuite.Variables.BaseURL + "tools/testing_start_apo.php";
   
      //  Checks if the currently for test runs used browser is already running.
      if(! Sys.WaitBrowser(testedBrowser).Exists)
      {
        //  If the browser is not running, starts it.
        Browsers.Item(testedBrowser).Run();
      }
      
      //  Opens a new tab.
      Sys.Browser(testedBrowser).BrowserWindow(0).Keys("^t");
      
      //  Opens URL to run the php cleanup script "testing_start_apo.php".
      Sys.Browser(testedBrowser).ToUrl(cleanupScriptUrl);
      
      //  Closes the tab in which the url was opened.
      Sys.Browser(testedBrowser).Page(cleanupScriptUrl).Close(); 
   }

When executing the function in Internet Explorer, everything works just fine. A new tab is opened, in that new tab the page with the correct url is opened, the tab is closed and Internet Explorer stays active.

 

When executing the function in Edge, when the tab in which the url was opened shall be closed, both the page and the browser are closed, instead of the page only.

 

When I execute the test operations manually without TestComplete, Edge behaves as it should and stays open.

 

The following picture shows both test logs, one for a test run with Edge, one for a test run with Internet Explorer:

 

Both browsers were prepared for testing as described in the Test Complete documentation. When Edge is used in TestComplete options the checkbox is checked for "Enable support for testing Windows Store applications".

 

Does anyone know why the whole edge browser is closed instead of the page only?

6 Replies

  • shankar_r's avatar
    shankar_r
    Community Hero

    Hi,

     

    I see one additional event came for Edge. Where it is going when you double click the entry highlighted in below image

    • S_Seydel's avatar
      S_Seydel
      Contributor

      Hi,

       

      the German expression in the highlighted log entry "und 1 weitere Seite" is in English "and 1 additional page".

      When I double click the highlighted entry it is going to the last line of script code:

       

      Sys.Browser(testedBrowser).Page(cleanupScriptUrl).Close();

      When I double click the last log entry it is going to the very same line of code.

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Best guess is that, what is happening, is that when you tell the test to go to the new URL for the clean up script, that is occurring, not on the new tab but potentially on the existing web page that is already open.  So, you really don't have two pages open, but a single one so, when you call the "Close" command, it closes the only page open which ends up closing the whole browser.  I'd do a bit of rework with your code to ensure that, when you open the new tab, you send your navigate code to that new page (probably your default home page or "blank" tab).