โ† Back to libraryQuestion 146 of 273
๐ŸงชSeleniumBeginner

Navigation Commands

๐Ÿ“– Detailed Explanation:

`driver.get(url)` loads a URL and waits for the whole page to load. `driver.navigate().to(url)` loads a URL and maintains browser history, allowing you to use `back()`, `forward()`, and `refresh()` methods. `navigate().back()` simulates the browser back button, `navigate().forward()` simulates forward, and `navigate().refresh()` reloads the current page.

๐ŸŒ Real-World Example:

get() is like typing a URL in the address bar for the first time. navigate().to() is like using the browser's history to revisit a page.

๐ŸŽฏ Scenario-Based Interview Question:

You need to test the 'Back' button functionality on an E-commerce site. Which command do you use to open the site?