Closing a Browser Window using different methods

Generally we use methods like driver.quit() or driver.close() to close the browser window.But sometimes it’s better to use other methods like actions which are available

//Using actions instead of driver.quit
Actions action = new Actions(driver);
action.sendKeys(Keys.chord(Keys.CONTROL+"w")).perform();


//if there are multiple tabs opened in driver window:
action.sendKeys(Keys.chord(Keys.CONTROL,Keys.SHIFT+"w")).perform

 

 

You may also like...