InterviewSolution
| 1. |
What is the use of the driver.get("URL") and driver.navigate().to("URL") commands? Are there any differences between the two? |
|
Answer» driver.get("URL") and driver.navigate().to("URL") both these commands are used to navigate to a URL passed as parameter. There is a very little difference between the two commands- driver.navigate() command maintains browser history or cookies to navigate back and forward and ALLOWS you moving back and forward in browser history USING driver.navigate().forward() and driver.navigate().back() commands. driver.navigate() command used to navigate to the particular URL and it does not wait to page load. In the CASE of a single page application, where the URL is appended by '#' to navigate to a DIFFERENT section of the page, driver.navigate().to() navigates to a particular page by changing the URL without refreshing the page whereas the driver.get() refreshes the page also and waits for the page to load. This refreshing of the page is also the primary reason because of which history is not maintained in the case of the driver.get() command. |
|