Can't switch window tabs

I am using the code of the WebAuthenticator.groovy file

link below:
https://dev.azure.com/linhnguyen0979/_git/KShare_GoogleAuthentication_macOS?path=%2FKeywords%2FWebAuthenticator.groovy&version=GBmaster
to fix the error that cannot be processed on Google Authenticator and it works then I use MightyText to get the OTP then Can’t switch windows to paste OTP on the website

1 Like

are you able to fetch right window handle?

hi @lethienhsr2401

how about using WebUI.switchToWindowTitle('') to switch between tabs?

or you can try this one to switch to tab on the right:

int currentWindow = WebUI.getWindowIndex()
WebUI.switchToWindowIndex(currentWindow + 1)
1 Like

What is that?

not works , i try switch window or JS but not works

can you share the error message

I swear the xpath is correct, but as I said, because I couldn’t focus on the window, I couldn’t find the xpath

find window count and then iterate for each window and see if it works

You might need something like below:

"open new tab"
WebUI.click(findTestObject('a'))
WebUI.waitForPageLoad(10)

"move into the new tab"
WebUI.switchToWindowIndex(1)

"verify element within the new tab"
WebUI.waitForElementVisible(findTestObject('b'), 10)
WebUI.verifyElementVisible(findTestObject('b'))

and then, depending if your additional tabs close or not, you can:

'close the second tab'
WebUI.closeWindowIndex(1)

'switch back to default content'
WebUI.switchToDefaultContent()

1 Like

@lethienhsr2401 did it work

Please try the below:

WebUI.switchToWindowTitle(‘name of the window title’)

change the name of the window title