2

I have scenario where clicking on some link in parent window opens a new window, after performing the actions on the child window, iam unable get back focus on the parent window, I have used the command driver.switchTo().window(parentWindowHandle) where parentWindowHandle is the window handler of parent window. I have also used the SeleniumWebDriver backed command selectWindow(parentWindowHandle) I am getting the error

org.openqa.selenium.WebDriverException: 'auto_id' does not refer to an open tab (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 15 milliseconds
Build info: version: '2.21.0', revision: '16552', time: '2012-04-11 19:08:38'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.7.0-ea'
Driver info: driver.version: ChromeDriver
Command duration or timeout: 31 milliseconds
Build info: version: '2.21.0', revision: '16552', time: '2012-04-11 19:08:38'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.7.0-ea'
Driver info: driver.version: TafRemoteWebDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:175)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:128)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:459)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:463)
    at com.socialtwist.taf.webdriver.TafRemoteWebDriver.getScreenshotAs(TafRemoteWebDriver.java:22)
    at com.socialtwist.taf.selenium.TafSelenium.screenShot(TafSelenium.java:1008)
    at com.socialtwist.taf.testnghelpers.CustomTestListener.afterInvocation(CustomTestListener.java:36)
    at org.testng.internal.invokers.InvokedMethodListenerInvoker$InvokeAfterInvocationWithoutContextStrategy.callMethod(InvokedMethodListenerInvoker.java:100)
    at org.testng.internal.invokers.InvokedMethodListenerInvoker.invokeListener(InvokedMethodListenerInvoker.java:62)
    at org.testng.internal.Invoker.runInvokedMethodListeners(Invoker.java:579)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:727)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:846)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1170)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
    at org.testng.TestRunner.runWorkers(TestRunner.java:1147)
    at org.testng.TestRunner.privateRun(TestRunner.java:749)
    at org.testng.TestRunner.run(TestRunner.java:600)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:317)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:312)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:274)
    at org.testng.SuiteRunner.run(SuiteRunner.java:223)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1049)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:974)
    at org.testng.TestNG.run(TestNG.java:905)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:203)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:174)
Caused by: org.openqa.selenium.WebDriverException: 'auto_id' does not refer to an open tab (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 15 milliseconds
Build info: version: '2.21.0', revision: '16552', time: '2012-04-11 19:08:38'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.7.0-ea'
Driver info: driver.version: ChromeDriver
Build info: version: '2.21.0', revision: '16552', time: '2012-04-11 19:08:38'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.7.0-ea'
Driver info: driver.version: ChromeDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:175)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:128)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:459)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:463)
    at org.openqa.selenium.chrome.ChromeDriver.getScreenshotAs(ChromeDriver.java:149)
    at org.openqa.selenium.remote.server.handler.CaptureScreenshot.call(CaptureScreenshot.java:36)
    at org.openqa.selenium.remote.server.handler.CaptureScreenshot.call(CaptureScreenshot.java:1)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:151)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

This is failing in Chrome, but the same is working in FireFox browser. I have used selenium-standalone-server-2.24.1.jar and Chrome driver 20 on Windows machine.

  • 1
    You say it works fine in firefox... Which browser is it not working in? – Sam Woods Jul 12 '12 at 20:40
2

Any of these strategies should work

driver.switchTo().window(driver.windowHandles[driver.windowHandles.count -1])

driver.switchTo().window(driver.windowHandles[0])
  • 2
    Welcome to SQA.SE... An explanation to help future readers would help?! – Andrew Dec 24 '12 at 9:02
0

I haven't specifically tried it in Chrome, but what build of WebDriver are you running? Have you tried updating to the latest to see if this is a bug that was fixed?

Have you tried

driver.switchTo().window(driver.windowHandles[driver.windowHandles.count -1])

? Or just

driver.switchTo().window(driver.windowHandles[0])

?

0

Have you tried driver.switchTo().defaultContent(); ?

  • 1
    If that works, I would like to understand why ;-) – dzieciou Dec 12 '12 at 18:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.