How to switch to different browser window from current window in Selenium webdriver?

Step1: Store the Main window handle
          

 String Parentwindow = driver.getWindowHandle( );  

Step2: Click on the Link which will open the new Browser window

Step3: Switch to the new open browser window.
          

  for ( String currentwindow : driver.getWindowHandles())  
driver.switchTo( ).window(currentwindow);
{
// Perform your operations on the current window
driver.close( )
}

Step4: Return to the Main window
          

  driver.switchTo().window(Parentwindow);  

Advertisements

One thought on “How to switch to different browser window from current window in Selenium webdriver?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s