Open link in the new tab doesn't work

Hi everyone,

I saw lots of people asking to open a link in a new tab, but it doesn’t solve mine. Right now, I can open a new tab but I try to navigate to the link with this code below:

@Keyword
def openNewtab() {

	KeywordUtil.logInfo("OpenNewtab")
	
	Robot robot = new Robot()
	robot.keyPress(KeyEvent.VK_CONTROL)
	robot.keyPress(KeyEvent.VK_T)
	robot.keyRelease(KeyEvent.VK_CONTROL)
	robot.keyRelease(KeyEvent.VK_T)
	robot.delay(3000);
	 
	 ArrayList<String> tabs = new ArrayList<String> (driver.getWindowHandles())
	 driver.switchTo().window(tabs.get(1))
	 driver.get("https://www.google.com")
	 robot.delay(3000)
}

After I tried to run it, I always get the error like the following. I’m not sure what did I do wrong. Why it doesn’t navigate to https://www.google.com in the new tab.

Thank you in advance for helping me. I’m a new joiner.