Discussion:
[selenium-users] target window already closed from unknown error: web view not found
s***@gmail.com
2018-09-04 05:57:54 UTC
Permalink
0down votefavorite
<https://stackoverflow.com/questions/52159579/target-window-already-closed-from-unknown-error-web-view-not-found#>

String mainWindow = driver.getWindowHandle();

driver.findElement(By.xpath(pro.getProperty(""))).click();

for(String newWindow : driver.getWindowHandles()){

driver.switchTo().window(newWindow);
}


driver.close();

Log.info("Closing the current Opened Window - Invoice");
driver.switchTo().window(mainWindow); ---error in this line

I am getting error while switching to main window. error is like:
org.openqa.selenium.NoSuchWindowException: no such window: target window
already closed from unknown error: web view not found

i have tried switching to default window, commenting driver.close and
adding thread.sleep also but issue not resolved.
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+***@googlegroups.com.
To post to this group, send email to selenium-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/22e834e4-d221-4d00-994a-081446055117%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Meenal Jain
2018-09-05 01:24:04 UTC
Permalink
Hi Sreedevi,

The error itself telling that the window you're trying to switch to is
already closed and it happened when you switched between multiple
tabs/windows through for loop and closed the tab/window you reached at
last. So here your for loop reaching your main tab at last which you're
closing once you're coming out of loop. To avoid closing of your main
tab,put condition in for loop to check if it is your main tab, if it is so
then don't switch to it.
Please let me know if you find any difficulty doing this.

Thanks,
Meenal
Post by s***@gmail.com
0down votefavorite
<https://stackoverflow.com/questions/52159579/target-window-already-closed-from-unknown-error-web-view-not-found#>
String mainWindow = driver.getWindowHandle();
driver.findElement(By.xpath(pro.getProperty(""))).click();
for(String newWindow : driver.getWindowHandles()){
driver.switchTo().window(newWindow);
}
driver.close();
Log.info("Closing the current Opened Window - Invoice");
driver.switchTo().window(mainWindow); ---error in this line
org.openqa.selenium.NoSuchWindowException: no such window: target window
already closed from unknown error: web view not found
i have tried switching to default window, commenting driver.close and
adding thread.sleep also but issue not resolved.
--
You received this message because you are subscribed to the Google Groups
"Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an
To view this discussion on the web visit
https://groups.google.com/d/msgid/selenium-users/22e834e4-d221-4d00-994a-081446055117%40googlegroups.com
<https://groups.google.com/d/msgid/selenium-users/22e834e4-d221-4d00-994a-081446055117%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+***@googlegroups.com.
To post to this group, send email to selenium-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAHd%3D%3DmJ2d0yR4_qD%3DXZ7fUGcKFdEBZ0%3DTi77b7MxwyGBVBcGfw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...