Wednesday, 29 October 2014

How to switch from one window to other using selenium webdriver?








//Returns all the available window id’s
Set<String> WINDOWIDS= driver.getWindowHandles();
Iterator<String> iter=WINDOWIDS.iterator();    
String Window1=iter.next();//Returns first window id
String Window2=iter.next();//Returns second window id
driver.switchTo().window(Window2);//Focus will be switched to second window

//Perform actions on Window2

driver.close();//It will close the second window
driver.switchTo().window(Window1);//Focus will be switched to first window

//Perform actions on Window1

driver.close();//It will close the first window


4 comments:

  1. Perfecto Mobile Survey Shows Increased Selenium WebDriver Usage --

    For agile mobile development, Selenium WebDriver has become a choice for many for testing within the development cycle because of its light-weight design, ability to trigger parallel executions, and flexibility to quickly work in many different development languages such as Java, Python, JavaScript, C#, etc., plus its usefulness to extend to any browser or device.

    ReplyDelete
  2. Congratulations on having One of the most sophisticated blogs Ive come throughout in a few time! Its just incredible how much you can remove from some thing thanks to how visually beautiful it’s. Youve put collectively an awesome blog space -great graphics, videos, layout. This can be undoubtedly a must-see weblog! TSWindowFilms.com

    ReplyDelete
  3. It is the type where the bottom part moves up and down while the top part is fixed in its place. The two-lite single slider type is the window where one side slides horizontally. https://www.westseattlewindowcleaner.com/window-cleaning-seattle-low-cost-and-high-quality

    ReplyDelete
  4. Extremely useful information which you have shared here about solar control window film. This is a great way to enhance knowledge for us, and also helpful for us. Thankful to you for sharing an article like this.

    ReplyDelete