In this blog we will be utilizing Playwright Java to launch non-incognito browser windows.
Topics that we will cover:
- Launch browser in incognito (private) mode
- Launch Non-Incognito (normal) Chromium Browser
- Launch Non-Incognito Chrome Browser
- Launch Non-Incognito Chrome Browser Default
Profile - Source code (incognito mode)
- Source code (Non-Incognito Chromium Browser)
- Source code (Non-Incognito Chrome Browser)
- Source code (Non-Incognito Chrome Browser Default Profile)
Launch browser in incognito (private) mode
So far we have been launching a browser in an incognito (private browser) mode.
This is the normal code that we have been running so far

Let us run this code to launch the private chromium browser. You can see ‘incognito’ mode in top right hand corner

Launch Non-Incognito (normal) “Chromium” Browser
At times we do NOT want to run a test in a private (incognito) browser. Instead we want to run the test in a “normal (non-incognito)” browser.
Let us see how to launch a chromium browser in a non-incognito window.
In order to launch a normal (non-incognito) browser, first of all what we need to do is, instead of “launch”, we have to use “launchPersistentContext” method. This method accepts 2 parameters : one is the path viz the browser profile that you need to give. If we don’t want to give path, we can keep it as blank as well:

Execute and note that a non-incognito window has been launched, it is not a private browser

Launch Non-Incognito “Chrome” Browser
Same thing we can do with chrome browser as well. We just need to setup the executable file path.
We can say .setExecutablePath(Paths.get(“”)) and give path of chrome exe: “C:\Program Files\Google\Chrome\Application\chrome.exe”

Launch Non-Incognito Chrome Browser Default Profile
In case you want to launch default chrome profile, than you can give the chrome profile path over here

Execute

As seen above, we now see the entire history as well. So this is not the new profile. This is the same profile that you are running it by default.
So this is how you can play around with profiles, you can launch multiple browser types (chrome, chromium etc) in non-incognito window using playwright.
package com.rsa.playwrightjava;
class Blog25_Incognito {
static
void main(String[] args) {
Source code (Non-Incognito Chromium Browser)
package com.rsa.playwrightjava;
class Blog25_NonIncognitoChromiumBrowser {
static
void main(String[] args) {
Source code (Non-Incognito Chrome Browser)
package com.rsa.playwrightjava;
class Blog25_NonIncognitoChromeBrowser {
static
void main(String[] args) {
Source code (Non-Incognito Chrome Browser Default Profile)
class Blog25_NonIncognitoChromeBrowserDefaultProfile {
static
void main(String[] args) {
