# How do i open a new tab in the same window?

**URL:** <https://forum.katalon.com/t/how-do-i-open-a-new-tab-in-the-same-window/127486>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [April 10, 2024, 8:20am UTC](https://forum.katalon.com/t/how-do-i-open-a-new-tab-in-the-same-window/127486 "2024-04-10T08:20:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sdahal](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/sdahal/32/23869_2.png) [@sdahal](https://forum.katalon.com/u/sdahal)\
**Post date:** [April 10, 2024, 8:20am UTC](https://forum.katalon.com/t/how-do-i-open-a-new-tab-in-the-same-window/127486/1 "2024-04-10T08:20:45Z")

</div>

I’m testing a web application that requires me to add a new tab in the same window and open a new url. For an example, i have [google.com](http://google.com) opened in 1 tab and need to open second tab [ktalon.com](http://ktalon.com). How do i achieve that? Please help.

---

<div class="post-metadata">

**Author:** ![grylion54](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/grylion54/32/16265_2.png) [@grylion54](https://forum.katalon.com/u/grylion54)\
**Post date:** [April 10, 2024, 2:53pm UTC](https://forum.katalon.com/t/how-do-i-open-a-new-tab-in-the-same-window/127486/2 "2024-04-10T14:53:29Z")

</div>

The below links lists several ways to open a new tab while you already have an open tab.

[[WebUI] How can I open a new Tab on Chrome? - Product Forums / Katalon Studio - Katalon Community](http://forum.katalon.com/t/webui-how-can-i-open-a-new-tab-on-chrome/5969/16)

> [@Switching between Tabs in Chrome issue](http://forum.katalon.com/t/switching-between-tabs-in-chrome-issue/8906/6):
>
> Try like this: #Switch to original WebUI.switchToWindowIndex(0) WebUI.delay(2) #And then switch to the second one. WebUI.switchToWindowIndex(1) WebUI.delay(2) With this, I can download from google drive where the download file is higher and google drive cannot scan and I was redirected to another page.

> [@How to open browser tabs in Chrome](http://forum.katalon.com/t/how-to-open-browser-tabs-in-chrome/23999):
>
> //Add the following to the import section of your test case or use "CTRL+SHIFT+O" import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI //Originally posted by Rajitha\_Kithuldeniya //http://forum.katalon.com/t/webui-how-can-i-open-a-new-tab-on-chrome/5969/10 //Add to the body of any test case WebUI.openBrowser('https://www.katalon.com/') WebUI.executeJavaScript('window.open();', []) currentWindow = WebUI.getWindowIndex() //Switches tab #1 WebUI.switchToWindowIndex(currentWindo…

---

<div class="post-metadata">

**Author:** ![Dave\_Evers](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/dave_evers/32/435_2.png) [@Dave\_Evers](https://forum.katalon.com/u/Dave_Evers)\
**Post date:** [April 10, 2024, 3:25pm UTC](https://forum.katalon.com/t/how-do-i-open-a-new-tab-in-the-same-window/127486/3 "2024-04-10T15:25:14Z")

</div>

You can try this one too: [How to open multiple Chrome browser tabs using Incognito](http://forum.katalon.com/t/how-to-open-multiple-chrome-browser-tabs-using-incognito/127534/1)

---

<div class="post-metadata">

**Author:** ![sdahal](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/sdahal/32/23869_2.png) [@sdahal](https://forum.katalon.com/u/sdahal)\
**Post date:** [April 11, 2024, 3:32am UTC](https://forum.katalon.com/t/how-do-i-open-a-new-tab-in-the-same-window/127486/4 "2024-04-11T03:32:54Z")

</div>

Achieve doing following

 ![Solution](https://europe1.discourse-cdn.com/katalon/original/3X/6/1/614b009c19d046abc6e8317feed6c5889c1f351c.png)

---

<div class="post-metadata">

**Author:** ![rp3696](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/rp3696/32/20464_2.png) [@rp3696](https://forum.katalon.com/u/rp3696)\
**Post date:** [September 13, 2024, 5:38am UTC](https://forum.katalon.com/t/how-do-i-open-a-new-tab-in-the-same-window/127486/5 "2024-09-13T05:38:44Z")

</div>

I think i figured out how to resolve this issue please see my example below and the TRICK i found out.

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint  
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase  
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData  
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject  
import static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject  
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint  
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW  
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile  
import com.kms.katalon.core.model.FailureHandling as FailureHandling  
import com.kms.katalon.core.testcase.TestCase as TestCase  
import com.kms.katalon.core.testdata.TestData as TestData  
import com.kms.katalon.core.testng.keyword.TestNGBuiltinKeywords as TestNGKW  
import com.kms.katalon.core.testobject.TestObject as TestObject  
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS  
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI  
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows  
import internal.GlobalVariable as GlobalVariable  
import org.openqa.selenium.Keys as Keys  
import org.openqa.selenium.By as By  
import org.openqa.selenium.WebDriver as WebDriver  
import org.openqa.selenium.WebElement as WebElement  
import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory  
import org.openqa.selenium.JavascriptExecutor as JavascriptExecutor

// Open the first website in a new tab  
WebUI.openBrowser(‘’)

// Go to the first Site on TAB 1  
WebUI.navigateToUrl(‘[https://www.google.com](https://www.google.com)’)

// Open the next TAB  
WebUI.executeJavaScript(“window.open();”, )

// Defining the Window Index  
currentWindow = WebUI.getWindowIndex()

// Switch to TAB or Window 1 - Current  
WebUI.switchToWindowIndex(currentWindow)

// Switch to TAB or Window 2  
WebUI.switchToWindowIndex(currentWindow + 1)

// Navigate to TAB or Window 2 Site  
WebUI.navigateToUrl(‘[https://www.att.com](https://www.att.com)’)

**// This is the Trick to make it work… DO IT AGAIN! This will open the URL**  
WebUI.switchToWindowIndex(currentWindow + 1)  
WebUI.navigateToUrl(‘[https://www.att.com](https://www.att.com)’)

// Now switch to whatever TAB or Window you want…  
WebUI.switchToWindowIndex(currentWindow)

// DO SOME ACTION ON THE CURRENT WINDOW  
WebDriver driver = DriverFactory.getWebDriver()  
‘To locate Search Bar’  
WebElement GoogleSearchBar = driver.findElement(By.xpath(‘//\*[@id=“APjFqb”]’))  
‘To locate Search Button’  
WebElement GoogleSearchButton = driver.findElement(By.xpath(“/html/body/div[1]/div[3]/form/div[1]/div[1]/div[4]/center/input[1]”))

// Perform actions on the Google page  
GoogleSearchBar.sendKeys(‘Katalon Studio’)  
GoogleSearchButton.click()

// TO OPEN ANOTHER TAB or WINDOW… **TRICK IS DO IT TWICE!**  
WebUI.executeJavaScript(“window.open();”, )  
WebUI.switchToWindowIndex(currentWindow + 2)  
WebUI.navigateToUrl(‘[https://www.apple.com](https://www.apple.com)’)  
WebUI.switchToWindowIndex(currentWindow + 2)  
WebUI.navigateToUrl(‘[https://www.apple.com](https://www.apple.com)’)

// NOW EXERCISE SWITCHING TO OTHER TABS  
WebUI.switchToWindowIndex(currentWindow + 1)  
WebUI.switchToWindowIndex(currentWindow)

---

<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:** [September 13, 2024, 5:38am UTC](https://forum.katalon.com/t/how-do-i-open-a-new-tab-in-the-same-window/127486/6 "2024-09-13T05:38:44Z")

</div>

Hi there, 👋

Thank you very much for your topic! It may take a little while before Katalon team member or others forum members respond to you.

In the meantime, you can _double-check_ your post to see if you can add any extra information i.e. error logs, HTML codes, screenshots, etc. Check out **[this posting guide](http://forum.katalon.com/t/tip-how-to-help-us-help-you/12919)** to **help us help you better!**

Thanks! 🕶  
Katalon Community team
