Forum Discussion

TanIlak's avatar
TanIlak
Contributor
10 months ago

Incognito mode

Hello Team,

I want to open my browser in incognito mode or i want to clear my browser history for one script. I tried to open incognito mode like this but it open as normal browser. I may did any mistakes here, let me know

 

function fn()

{

var browser=["chrome","edge"]

for(var k=0;k<browsers.length;k++)

{

Browsers.Item(browsers[k]).RunOptions= "--incognito"

Browsers.Item(browsers[k]).Run(URL);

 

----------

}}

 

or give me an option to delete browser history.

 

Thanks in Advance!

 

5 Replies

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    The code example to run in incognito is,

    function SetChromeRunOptions()
    {
        Browsers.Item("chrome").RunOptions = "--incognito";
        Browsers.Item("chrome").Run("https://smartbear.com/");
    }

     and you need to enable the following for Test Extension

     

  • KB1's avatar
    KB1
    Champion Level 2

    Or to delete the browser history.

     

    function deleteHistory()
    {
      let browser = Aliases.Sys.browser;
      Browsers.Item(btChrome).Navigate("chrome://history/");
      let page = browser.pageHistory;
      page.Wait();
      page.Keys("^a[Del]");
      page.Keys("[Enter]");
    }

     

     Reasoning why I chose the keys option instead of clicking on screen is why. for some reason I cannot click with testcomplete in the settings of chrome. But this will do the Job I'm also using this my self in my tests. 


    • TanIlak's avatar
      TanIlak
      Contributor

      KB1 Thanks for your response. Even i tried to click with test complete after opening cntrl+H it won't works. so, only i came here.