driver.close() VS. driver.quit()

Id

                                                                              Detail

driver.quit()

It basically calls driver.dispose() method which in turn closes all the browser windows and ends the WebDriver session gracefully.

Usability
It is best to use driver.quit() when we no longer want to interact with the driver object along with any associated window, tab or pop-up. Generally it is one of the last statements of the automation scripts. In case, we are working with Selenium with TestNG or JUnit, we call driver.quit() in the @AfterSuite method of aur suite. Thus, closing it at the end of whole suite.

driver.close()

close() is a webdriver command which closes the browser window which is currently in focus. ... The remaining browser windows will not be closed.

Usability
It is best to use driver.close() when we are dealing with multiple browser tabs or windows e.g. when we click on a link that opens another tab. In this case after performing required action in the new tab, if we want to close the tab we can call the driver.close() method.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章