# How to Test Two Browsers using WebDriver

**URL:** <https://forum.katalon.com/t/how-to-test-two-browsers-using-webdriver/51133>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [January 16, 2021, 8:45pm UTC](https://forum.katalon.com/t/how-to-test-two-browsers-using-webdriver/51133 "2021-01-16T20:45:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndyCapp](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/andycapp/32/15712_2.png) [@AndyCapp](https://forum.katalon.com/u/AndyCapp)\
**Post date:** [January 16, 2021, 8:45pm UTC](https://forum.katalon.com/t/how-to-test-two-browsers-using-webdriver/51133/1 "2021-01-16T20:45:18Z")

</div>

Hi Russ\_Thomas,

I think that @Hariprasad1 was referring to two browsera.  
Anyway, I have the same problems when I have to switch from one browser to another.

Following my script into TestCase:

System.setProperty(‘webdriver.chrome.driver’, DriverFactory.getChromeDriverPath())  
WebDriver driver1 = new ChromeDriver()  
WebDriver driver2 = new ChromeDriver()

// first browser  
DriverFactory.changeWebDriver(driver1)  
WebUI.openBrowser(’’)  
WebUI.navigateToUrl(‘MY HTTPS A’)  
//some action

// second browser  
DriverFactory.changeWebDriver(driver2)  
WebUI.openBrowser(’’)  
WebUI.navigateToUrl(‘MY HTTPS B’)  
//some action

//I need come back into first browser.How can I do?  
//some action  
//I nedd come backe into secondo browser. How can I do?

Thanks  
AndyCapp

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [January 16, 2021, 9:33pm UTC](https://forum.katalon.com/t/how-to-test-two-browsers-using-webdriver/51133/2 "2021-01-16T21:33:59Z")

</div>

Try this code:

```auto
import org.openqa.selenium.WebDriver
import org.openqa.selenium.chrome.ChromeDriver
import com.kms.katalon.core.webui.driver.DriverFactory
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

System.setProperty("webdriver.chrome.driver", 
  DriverFactory.getChromeDriverPath())

WebDriver driver1 = new ChromeDriver()
WebDriver driver2 = new ChromeDriver()

// first browser
DriverFactory.changeWebDriver(driver1)
WebUI.navigateToUrl("https://www.duckduckgo.com")

// second browser
DriverFactory.changeWebDriver(driver2)
WebUI.navigateToUrl("https://www.google.com")

// first browser
DriverFactory.changeWebDriver(driver1)
WebUI.maximizeWindow()

// second browser, navigate from duckduckgo to Katalon
DriverFactory.changeWebDriver(driver2)
WebUI.navigateToUrl("https://katalon.com")

```

Tested in Katalon Studio 7.9.0rc

 ![image](https://europe1.discourse-cdn.com/katalon/original/2X/3/3ab0c06deaaef3976634e1898aaede04fbe3703b.png)

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [January 16, 2021, 9:36pm UTC](https://forum.katalon.com/t/how-to-test-two-browsers-using-webdriver/51133/3 "2021-01-16T21:36:07Z")

</div>

p.s. Andy Cap 🤣

He wouldn’t get far in today’s “pc” environment 😉

---

<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:** [January 17, 2021, 12:58am UTC](https://forum.katalon.com/t/how-to-test-two-browsers-using-webdriver/51133/4 "2021-01-17T00:58:30Z")

</div>

Similar issue:

> [@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:** ![AndyCapp](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/andycapp/32/15712_2.png) [@AndyCapp](https://forum.katalon.com/u/AndyCapp)\
**Post date:** [January 17, 2021, 9:20pm UTC](https://forum.katalon.com/t/how-to-test-two-browsers-using-webdriver/51133/5 "2021-01-17T21:20:31Z")

</div>

Thanks @Russ_Thomas, the code work very well 🥳

---

<div class="post-metadata">

**Author:** ![eric.fabiszewski](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/eric.fabiszewski/32/28140_2.png) [@eric.fabiszewski](https://forum.katalon.com/u/eric.fabiszewski)\
**Post date:** [July 11, 2024, 4:44pm UTC](https://forum.katalon.com/t/how-to-test-two-browsers-using-webdriver/51133/6 "2024-07-11T16:44:34Z")

</div>

whenever i used the setproperty its still using the katalon driver and not the specified path to the driver

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/2/f/2f213ac657523c34916b976d46aab4634ab17c1d.png)

The last line shows “Chrome Path C:\Program Files\Katalon Studio\configuration\resources\drivers\chromedriver\_win32\chromedriver.exe” instead of the one in set property

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/katalon/original/3X/d/5/d55596ab02785a255798e87ede769734747b30c4.svg) [@system](https://forum.katalon.com/u/system)\
**Post date:** [July 11, 2024, 4:44pm UTC](https://forum.katalon.com/t/how-to-test-two-browsers-using-webdriver/51133/7 "2024-07-11T16:44:34Z")

</div>

Hi there,

Thank you very much for your topic. Please note that it may take a little while before a member of our community or from Katalon team responds to you.

Thanks!

---

<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:** [July 15, 2024, 1:38pm UTC](https://forum.katalon.com/t/how-to-test-two-browsers-using-webdriver/51133/9 "2024-07-15T13:38:16Z")

</div>

> [@eric.fabiszewski](#):
>
> whenever i used the setproperty its still using the katalon driver

@eric.fabiszewski

You have a misunderstanding.

```auto
WebDriver driver = new ChromeDriver()
DriverFactory.changeWebDriver(driver)

KeywordUtil.logInfo('Chrome Path ' + DriverFactory.getChromeDriverPath())

```

Do you expect that a call to `DriverFactory.getChromeDriverPath()` will return the path from which the WebDriver instance (named `driver`) were instanciated?

No. The system does not work as you expect.

The call to `DriverFactory.getChromeDriverPath()` will always return the path of the chromedriver.exe bundled in the Katalon Studio distribution, which is static and never changes.

Then, is there any way to get the path from which the WebDriver instance named `driver` was instanciated from? — I am sure that the `org.openqa.selenium.WebDriver` does not implement such a method. But, as you already know, you are required to set the value of System Property `webdriver.chrome.driver` before calling `new ChromeDriver()` so that you are always aware of the path value. You don’t need that magical method.
