Launch Browser in Incognito/Private Mode
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Launch Browser in Incognito/Private Mode
Thought of sharing the code in the community for launching browsers in their incognito modes. The function is parameterized such a way to run for the browsers Internet Explorer, Edge, Chrome and Firefox.
Hope it will be useful for more people.
function runIncognitoMode(browserName){
//var browserName = "firefox" //iexplore,edge,chrome,firefox
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
}
if(browserName=="edge"){
Browsers.Item(btEdge).RunOptions = "-inprivate"
Delay(3000)
Browsers.Item(btEdge).Run();
}else if (browserName=="iexplore"){
Browsers.Item(btIExplorer).RunOptions = "-private"
Delay(3000)
Browsers.Item(btIExplorer).Run();
}else if (browserName=="chrome"){
Browsers.Item(btChrome).RunOptions = "-incognito"
Delay(3000)
Browsers.Item(btChrome).Run();
}else if (browserName=="firefox"){
Browsers.Item(btFirefox).RunOptions = "-private"
Delay(3000)
Browsers.Item(btFirefox).Run();
}
Sys.Browser(browserName).BrowserWindow(0).Maximize()
}
- Labels:
-
Chrome
-
Firefox
-
IE
-
TechCorner
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This worked perfectly for us. We then hit a different problem, but wondered if you had any guidance. How to navigate to a URL in the Running InCognito Edge Browser.
We are able to maximize the browser, retrieve properties from the browsers, etc., but unable to navigate.
the webBrowser variable is passed into our function as Edge, Firefox, etc.
Browsers.Item[webBrowser].RunOptions="-inprivate"
Browsers.Item[webBrowser].Run()
Delay(4732)
browserWin = Sys.Browser(webBrowser).BrowserWindow(0)
browserWin.Maximize()
browserWin.Activate()
currentTitle = browserWin.WndCaption
Log.Message("Before using the ToUrl method")
Log.Message("title of brwoser: " + currentTitle)
# can't find the page, even though it can maximize & get the browser title -- :-(
browserWin.ToUrl(url, 7233)
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Found the answer on this ...
https://community.smartbear.com/t5/TestComplete-Questions/Incognito-mode-of-Chrome-not-navigating-to...
