Lee_M's avatar
Lee_M
Community Hero
4 years ago
Status:
New Idea

Browser Loop - incognito mode

I can create a browser loop in a Keyword test.

Some Webinars suggest running tests in private or incognito mode as you would more accurately simulate the first use and discard any cache issues

 

I would be handly to add this feature to the Loop condition

Currently, the only way on doing this is by using TestApps or call a CLI script - either way, it is harder testing these within a loop

1 Comment

  • Lee_M's avatar
    Lee_M
    Community Hero

    update:

     

    my tests all now start a 2-step open process

     

    1, testedApp calling batch file for flush cache
             file code:
                        ipconfig /flushdns

     

    2, function script with incognito mode
             - make sure testcomplete extension is enabled for incognito mode !!

     

     


     navigate browser as normal






    ALL tests now run incognito and a free of any cache issues
    - this can be hooked up to any start event or login process as the tests require





     

    Here is my code for step 2 in case it helps anyone (Javascript)

     

    ---------------------------------

     

    function open_secret_browser(browserName = "chrome"){
    
    switch (browserName) {
    case "edge":
    browserName = "edge";
    browserType = btEdge;
    break;
    case "firefox":
    browserName = "firefox";
    browserType = btFirefox;
    break;
    case "chrome":
    default:
    browserName = "chrome";
    browserType = btChrome;
    }
    
    browserName = aqString.ToLower(browserName);
    
    TestedApps.clear_cache.Run();
    
    if (Sys.WaitBrowser(browserName).Exists){
    var browser = Sys.Browser(browserName);
    Log.Enabled = false // To disable the warning that might occur during closing of the browser
    browser.Close();
    Log.Enabled = true // enabling the logs back
    }
    
    Delay(500)
    switch (browserName) {
    case "edge":
    Browsers.Item(btEdge).RunOptions = "-inprivate";
    break;
    case "firefox":
    Browsers.Item(btFirefox).RunOptions = "-private-window";
    break;
    case "chrome":
    default:
    Browsers.Item(btChrome).RunOptions = "-incognito";
    
    }
    
    Browsers.Item(browserType).Run();
    Sys.Browser(browserName).BrowserWindow(0).Maximize()
    }