WebUI.closeWindowIndex is not working after setting the viewport 768 * 1024

Hi,

I am testing a webpage for a medium screen size (768 * 1024). I am not able to close the window index and switch back to the first window.
Given below is the script which i am running:

WebUI.setViewPortSize(768, 1024, FailureHandling.STOP_ON_FAILURE)

int winIdx = WebUI.getWindowIndex()

WebUI.verifyElementVisible(findTestObject('Object Repository/KeyPages/HomePage/MediumSmallScreen/Cart'), FailureHandling.CONTINUE_ON_FAILURE)
WebUI.enhancedClick(findTestObject('Object Repository/KeyPages/HomePage/MediumSmallScreen/Cart'))

winIdx = winIdx + 1
WebUI.switchToWindowIndex(winIdx)

WebUI.delay(GlobalVariable.MediumDelay)

WebUI.switchToDefaultContent()

String CurrEcomUrl = WebUI.executeJavaScript("return window.location.href;", null)

println("Current URL: " + CurrEcomUrl)

WebUI.verifyEqual(CurrEcomUrl, GlobalVariable.EcomUrl)

WebUI.closeWindowIndex(winIdx)
winIdx--

WebUI.switchToWindowIndex(winIdx)

WebUI.delay(GlobalVariable.MediumDelay)

Pls help and thanks in advance!!!

Hello, I would have written it like that :

//First tab
WebUI.setViewPortSize(768, 1024, FailureHandling.STOP_ON_FAILURE)
WebUI.verifyElementVisible(findTestObject('Object Repository/KeyPages/HomePage/MediumSmallScreen/Cart'), FailureHandling.CONTINUE_ON_FAILURE)
WebUI.enhancedClick(findTestObject('Object Repository/KeyPages/HomePage/MediumSmallScreen/Cart'))

switchToNextTab()

//Second tab
String CurrEcomUrl = WebUI.executeJavaScript("return window.location.href;", null)
println("Current URL: " + CurrEcomUrl)
WebUI.verifyEqual(CurrEcomUrl, GlobalVariable.EcomUrl)

closeTabAndSwitchBackToDefault()

//First tab
WebUI.delay(GlobalVariable.MediumDelay)


def switchToNextTab() {
	WebUI.switchToWindowIndex((WebUI.getWindowIndex()+1))
}

def closeTabAndSwitchBackToDefault() {
	int currentTab = WebUI.getWindowIndex()
	WebUI.closeWindowIndex(currentTab)
	WebUI.switchToWindowIndex(currentTab-1)
}

Hope it’ll help you ! :slight_smile:

Thanks @arthur.rallon
The problem got solved by just removing the medium delay after switching to the next tab.