# How does one open 1 normal chrome browser and 1 incognito chrome browser?

**URL:** <https://forum.katalon.com/t/how-does-one-open-1-normal-chrome-browser-and-1-incognito-chrome-browser/63724>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [March 25, 2022, 9:15pm UTC](https://forum.katalon.com/t/how-does-one-open-1-normal-chrome-browser-and-1-incognito-chrome-browser/63724 "2022-03-25T21:15:25Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomas.bates](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/thomas.bates/32/16104_2.png) [@thomas.bates](https://forum.katalon.com/u/thomas.bates)\
**Post date:** [March 25, 2022, 9:15pm UTC](https://forum.katalon.com/t/how-does-one-open-1-normal-chrome-browser-and-1-incognito-chrome-browser/63724/1 "2022-03-25T21:15:25Z")

</div>

Hi all

So I was wondering how one opens 1 instance of a normal chrome browser and 1 instance of incognito chrome browser.

This [link](http://forum.katalon.com/t/how-to-open-2-chrome-browser-windows-and-perform-test-on-both-simultaneously/50264) supposedly figured it out, and when I copied the script to Katalon, it indeed opened two instances of chrome, and worked on them simultaneously, however the one was sadly not incognito.

I am assuming that this is supported now, as it was possible, and that it is possible to have two instances of chrome browsers open and switch back and forth between them. But to do my software testing I need to be able to use an incognito mode so that my sessions don’t get mixed up

**PLEASE NOTE:** I know that one can in the preferences set chrome to open in incognito, however I specifically need 1 instance to be normal chrome and 1 instance to be incognito

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [March 25, 2022, 11:55pm UTC](https://forum.katalon.com/t/how-does-one-open-1-normal-chrome-browser-and-1-incognito-chrome-browser/63724/2 "2022-03-25T23:55:47Z")

</div>

> [@How to open 2 Chrome browser windows and perform test on both simultaneously](http://forum.katalon.com/t/how-to-open-2-chrome-browser-windows-and-perform-test-on-both-simultaneously/50264):
>
> Problem to solve In a single Katalon Test Case, I want to open 2 windows of Chrome Browser. One in normal mode, another in [Incognito mode](https://support.google.com/chrome/answer/95464?co=GENIE.Platform%3DDesktop&hl=en). I want to perform various testing actions on each browser window using WebUI.\* keywords as usual. I want to repeat switching between 2 windows back and forth. Why Incognito mode Quote from [Cybersecurity Training & Software | MetaCompliance](https://www.metacompliance.com/blog/3-reasons-to-browse-the-internet-in-incognito-mode/) Multiple sessions – One of the great advantages of going Incognito, is it enables you to sign in to multiple accou…

---

<div class="post-metadata">

**Author:** ![Brandon\_Hein](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/brandon_hein/32/1092_2.png) [@Brandon\_Hein](https://forum.katalon.com/u/Brandon_Hein)\
**Post date:** [March 26, 2022, 12:06am UTC](https://forum.katalon.com/t/how-does-one-open-1-normal-chrome-browser-and-1-incognito-chrome-browser/63724/3 "2022-03-26T00:06:05Z")

</div>

The topic you linked has the correct idea, you just need to add the --incognito argument to the driver instance that you want to be incognito. I think this is what’s intended in that post, they just don’t show the implementation (at least I couldn’t find it easily). I’m talking about this part:

```auto
WebDriver incognitoChrome = openChromeBrowserInIncognitoMode()

```

(openChromeBrowserInIncognitoMode() is not shown) Here’s how to do it yourself:

```auto
ChromeOptions options = new ChromeOptions()
options.addArgument('--incognito')
WebDriver incognitoChrome = new ChromeDriver(options)

```

Here’s the full example, with the above replaced:

```auto
// open 2 Chrome browser, one in normal mode on the left, another in incognito mode on the right
WebDriver normalChrome = openChromeBrowserPlain()
resizeHorizontalHalfLocateLeft(normalChrome)
DriverFactory.changeWebDriver(normalChrome)
WebUI.navigateToUrl('http://demoaut.katalon.com/')
WebUI.waitForPageLoad(10)

ChromeOptions options = new ChromeOptions()
options.addArgument('--incognito')
WebDriver incognitoChrome = new ChromeDriver(options)
resizeHorizontalHalfLocateRight(incognitoChrome)
DriverFactory.changeWebDriver(incognitoChrome)
WebUI.navigateToUrl('http://demoaut-mimic.kazurayam.com/')
WebUI.waitForPageLoad(10)

// in the normal Chrome, do something
DriverFactory.changeWebDriver(normalChrome)
WebUI.comment("switched to ${WebUI.getUrl()}")
WebUI.verifyElementPresent(button, 10, FailureHandling.STOP_ON_FAILURE)
WebUI.click(button)
WebUI.delay(1)

// in the incoginto Chrome, do something
DriverFactory.changeWebDriver(incognitoChrome)
WebUI.comment("switched to ${WebUI.getUrl()}")
WebUI.navigateToUrl('http://demoaut-mimic.kazurayam.com/')
WebUI.click(button)
WebUI.delay(1)

// close 2 browser windows
DriverFactory.changeWebDriver(normalChrome)
WebUI.closeBrowser()
WebUI.delay(1)
DriverFactory.changeWebDriver(incognitoChrome)
WebUI.closeBrowser()

```

---

<div class="post-metadata">

**Author:** ![Brandon\_Hein](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/brandon_hein/32/1092_2.png) [@Brandon\_Hein](https://forum.katalon.com/u/Brandon_Hein)\
**Post date:** [March 26, 2022, 12:29am UTC](https://forum.katalon.com/t/how-does-one-open-1-normal-chrome-browser-and-1-incognito-chrome-browser/63724/4 "2022-03-26T00:29:41Z")

</div>

@kazurayam I found a small issue in your code that’s causing this to not work as intended for OP. In your openChromeBrowserInIncognitoMode() method, when you add the incognito argument, you need 2 dashes. Here’s your current code snippet:

```auto
ChromeDriver openChromeBrowserInIncognitoMode() {
	ChromeOptions options = new ChromeOptions()
	options.addArguments("-incognito")
	return openChromeBrowser(options);
}

```

It needs to be:

```auto
ChromeDriver openChromeBrowserInIncognitoMode() {
	ChromeOptions options = new ChromeOptions()
	options.addArguments("--incognito")
	return openChromeBrowser(options);
}

```

---

<div class="post-metadata">

**Author:** ![thomas.bates](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/thomas.bates/32/16104_2.png) [@thomas.bates](https://forum.katalon.com/u/thomas.bates)\
**Post date:** [March 26, 2022, 1:07pm UTC](https://forum.katalon.com/t/how-does-one-open-1-normal-chrome-browser-and-1-incognito-chrome-browser/63724/5 "2022-03-26T13:07:50Z")

</div>

Thank you for this. It works now.

However for some reason I am having trouble that some of my objects don’t want to work at all, and I don’t know why.

Is there any easier way to do this? Like a simpler way?

---

<div class="post-metadata">

**Author:** ![Brandon\_Hein](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/brandon_hein/32/1092_2.png) [@Brandon\_Hein](https://forum.katalon.com/u/Brandon_Hein)\
**Post date:** [March 26, 2022, 5:57pm UTC](https://forum.katalon.com/t/how-does-one-open-1-normal-chrome-browser-and-1-incognito-chrome-browser/63724/6 "2022-03-26T17:57:33Z")

</div>

> [@thomas.bates](#):
>
> Is there any easier way to do this? Like a simpler way?

Not really, no. You could simplify a few things, namely you can put this in a keyword, then you wouldn’t need to do this in every script. Another idea would be to have two separate scripts that each use a different browser (normal/incognito) and run them in parallel, but I don’t know if that fits your use case.

---

<div class="post-metadata">

**Author:** ![Brandon\_Hein](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/brandon_hein/32/1092_2.png) [@Brandon\_Hein](https://forum.katalon.com/u/Brandon_Hein)\
**Post date:** [March 26, 2022, 7:05pm UTC](https://forum.katalon.com/t/how-does-one-open-1-normal-chrome-browser-and-1-incognito-chrome-browser/63724/7 "2022-03-26T19:05:32Z")

</div>

> [@thomas.bates](#):
>
> However for some reason I am having trouble that some of my objects don’t want to work at all, and I don’t know why.

Do you have an example of this that we can look at?

---

<div class="post-metadata">

**Author:** ![thomas.bates](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/thomas.bates/32/16104_2.png) [@thomas.bates](https://forum.katalon.com/u/thomas.bates)\
**Post date:** [March 26, 2022, 8:39pm UTC](https://forum.katalon.com/t/how-does-one-open-1-normal-chrome-browser-and-1-incognito-chrome-browser/63724/8 "2022-03-26T20:39:21Z")

</div>

When I have a normal instance of chrome open, using **WebUI.openBrowser()**, I can use the following script to set the text:

`// Sets the OTP from the Noted Feedback as a variable "OTP"`  
`OTP = WebUI.getText(findTestObject('Enrolment/Page_Connect - Operations - Student Enrolment/span_6031'))`

```
// On the modal, enters the OTP by pasting the OTP variable that it stored
WebUI.setText(findTestObject('Enrolment/Page_Connect - Operations - Student Enrolment/input_Please check your junk mail folder if_d47c1f'), 
    OTP)

```

Where the xpath of the set text test object is **//input[@id=‘VerificationOTP’]**

However, if I have a normal instance of chrome open using the following method, then this doesn’t work:

```
// open normal Chrome browser on the left side
WebDriver normalChrome = openChromeBrowserPlain()

resizeHorizontalHalfLocateLeft(normalChrome)

DriverFactory.changeWebDriver(normalChrome)

WebUI.navigateToUrl('www.google.com')

WebUI.waitForPageLoad(10)

// open incognito Chrome browser on the right side
ChromeOptions options = new ChromeOptions()

options.addArguments('--incognito')

WebDriver incognitoChrome = new ChromeDriver(options)

resizeHorizontalHalfLocateRight(incognitoChrome)

DriverFactory.changeWebDriver(incognitoChrome)

WebUI.navigateToUrl('www.youtube.com')

WebUI.waitForPageLoad(10)

```

This is the example of the Test Object that doesn’t work

---

<div class="post-metadata">

**Author:** ![Brandon\_Hein](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/brandon_hein/32/1092_2.png) [@Brandon\_Hein](https://forum.katalon.com/u/Brandon_Hein)\
**Post date:** [March 27, 2022, 6:55am UTC](https://forum.katalon.com/t/how-does-one-open-1-normal-chrome-browser-and-1-incognito-chrome-browser/63724/9 "2022-03-27T06:55:05Z")

</div>

What we really need is the error you are getting.

---

<div class="post-metadata">

**Author:** ![Brandon\_Hein](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/brandon_hein/32/1092_2.png) [@Brandon\_Hein](https://forum.katalon.com/u/Brandon_Hein)\
**Post date:** [March 27, 2022, 7:06am UTC](https://forum.katalon.com/t/how-does-one-open-1-normal-chrome-browser-and-1-incognito-chrome-browser/63724/10 "2022-03-27T07:06:23Z")

</div>

Nevermind, I see your other topic: [Element Not Interactable in a certain test case](http://forum.katalon.com/t/element-not-interactable-in-a-certain-test-case/63748)

Marking a solution and closing this topic.

---

<div class="post-metadata">

**Author:** ![Brandon\_Hein](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/brandon_hein/32/1092_2.png) [@Brandon\_Hein](https://forum.katalon.com/u/Brandon_Hein)\
**Post date:** [March 27, 2022, 7:06am UTC](https://forum.katalon.com/t/how-does-one-open-1-normal-chrome-browser-and-1-incognito-chrome-browser/63724/11 "2022-03-27T07:06:49Z")

</div>


