Web Recorder cannot open new tab

I am currently testing this website that displays new tab when I am done with the process, I cannot finish the process since Katalon Studio Codeless Web Recorder cannot open new tab. What solution did you guys do when you encountered this problem? Thanks!

The code below can be added to make a Keyword that you can use to open a second tab. You can either supply the Keyword with an URL or you can create a second Keyword that does not need a parameter but you can use a Global Variable to supply the URL instead. You can also close the second tab by calling the close routine either from within the open routine or by Keyword if you want.

import java.awt.Robot
import java.awt.Toolkit
import java.awt.datatransfer.StringSelection
import java.awt.event.KeyEvent

	/*
	 * This routine opens a second tab, sets the ....
	 */
	@Keyword
	def openSecondTab(String siteURL) {

		Robot robot = new Robot()
		robot.keyPress(KeyEvent.VK_CONTROL)
		robot.keyPress(KeyEvent.VK_T)
		robot.keyRelease(KeyEvent.VK_CONTROL)
		robot.keyRelease(KeyEvent.VK_T)
		WebUI.waitForPageLoad(10)

		WebUI.switchToWindowIndex(1)

		WebUI.navigateToUrl(siteURL)
		WebUI.waitForPageLoad(10)

		WebUI.waitForElementVisible(findTestObject('...'), 10)

     }

	/*
	 * This routine closes the second tab.
	 */
	@Keyword
	def closeSecondTab() {

		"close this tab"
		Robot robot = new Robot()
		robot.keyPress(KeyEvent.VK_CONTROL)
		robot.keyPress(KeyEvent.VK_W)
		robot.keyRelease(KeyEvent.VK_CONTROL)
		robot.keyRelease(KeyEvent.VK_W)
	}

Edit: when using the Robot, you cannot be using the mouse or keyboard at the same time as it is running!
Edit2: If you make two Keywords of openSecondTab, you have to remove the parameter (or change the number of parameters) the Keyword has in the second Keyword.

Robot is a nice touch, but I prefer:

WebUI.executeJavaScript('window.open();', [])

Then you can switch to the new window and continue your work.

2 Likes

Did you find out solution ?

Did you find the solution?