Selenium Webdriver Appium Complete TutorialSelenium Webdriver Appium Complete Tutorial
Automation Testing
  • Tools
    • Selenium
      • Selenium Java Tutorial
      • Selenium C# Tutorial
    • Appium
      • Appium Java Tutorial
      • Appium C#Tutorial
    • Katalon
  • Trainings
  • TestNG
  • Reports
    • Extent Reports
      • Extent Reports – Java
      • Extent Reports – Java -Version3
      • Extent Reports – C#
    • Vigo Reports
    • AT Excel Report
  • Excel
    • Apache POI – Java
    • Excel With C#
  • Interview Questions
    • Selenium Interview Questions
    • Java Interview Questions
    • C# Interview Questions
  • Demo Site
  • Practice Site
  • More…
    • AutoIt
    • Sikuli
    • Robot Class
    • File Upload
    • ScreenShot
      • AShot
      • ShutterBug
  • About
December 12, 2016

Selenium NoSuchWindowException





Selenium NoSuchWindowException is similar to NoSuchFrameException, this is also one of the frequent exceptions which we will face in selenium webdriver. Sometimes applications will have child windows(i.e. Separate windows) which will open when you click on any link or button. Normally if you want to automate the child windows then you need to switch to that window then only you can interact with the elements which are there on that window. To overcome this, we need to handle the opened windows using one of the webdriver methods called “driver.getWindowHandles()”. Once  you have this information then you can switch to the corresponding window to automate or interact with the window.

Below are the causes to face this exception:

  1. This exception is caused because the list of windows hold by the driver.getWindowHandles() method is not up to date. One of the windows that previously existed is no longer exists; so, you can not switch to that window. To handle this we need to make sure that you are not closing a window without refreshing the available list of windows using this method.
  2. The other reason behind this exception is that you may trying to switch to window before handling all the opened windows using driver.getWindowHandles() method. And we need to keep in mind that we should know which window we are trying to switch as getWindowHandles() holds all the windows which are opened. To get the main window then you can use one the webdriver methods called “driver.getWindowHandle()”. Once you have all the windows with you then you can loop through all the windows which are there in the list and we can switch to the desired window.

Once you done with your work, then you need to come to the parent or default windows then only your execution will be smooth. This way can overcome the NoSuchWindowException in selenium webdriver.

Please watch the YouTube video for this blog for better understanding.



Share this post: on Twitter on Facebook on Google+

Selenium NoSuchFrameException Understanding testng.xml file

Related Posts

TAKING WEB ELEMENT SCREENSHOT IN SELENIUM

Selenium - Java

How to Capture WebElement Screenshot in Selenium Webdriver using selenium 4

avoid Switch to window

Selenium - Java

How to Avoid Switch To Window in Selenium WebDriver

webdrivermanager

Selenium - Java

No More Driver EXE files for Selenium Execution – Instead Use WebDriverManager

HANDLE TEXTBOXES IN SELENIUM

Selenium - Java

Handling Textboxes in Selenium

JAVASCRIPTEXECUTOR IN SELENIUM

Selenium - Java

JavaScriptExecutor in Selenium

ELEMENT NOT VISIBLE EXCEPTION

Selenium - C#, Selenium - Java

Selenium ElementNotVisibleException

NOSUCHFRAME EXCEPTIONS

Selenium - C#, Selenium - Java

Selenium NoSuchFrameException

NOSUCHELEMENT EXCEPTION

Selenium - C#, Selenium - Java

Selenium NoSuchElementException

SELENIUM WEBDRIVER EXCEPTIONS

Selenium - C#, Selenium - Java

Selenium WebDriver Exceptions

HANDLING BASIC ELEMENTS IN SELENIUM

Selenium - C#, Selenium - Java

Handling Basic Elements in Selenium

Newsletter

Recent Posts

  • TAKING WEB ELEMENT SCREENSHOT IN SELENIUMHow to Capture WebElement Screenshot in Selenium Webdriver using selenium 4
    December 15, 2019
  • How To SWAP Two Numbers in Java Without using Temp VariableHow to SWAP Two Numbers in Java Without Temp variable or Without Third variable
    December 8, 2019
  • How to Swap Two Numbers in Java with Temp VariableHow to SWAP Two Numbers in Java using Temp Variable
    December 1, 2019
  • How to Read Properties file in JavaHow to Read Data From Properties File in Java
    November 27, 2019
  • Compare two arrays in java with out inbuilt functionsHow to Compare Two Arrays in Java without built-in functions
    November 16, 2019
© Selenium Webdriver Appium Complete Tutorial 2023