- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are the differences between get() and navigate() method?
The differences between get() and navigate() methods are listed below.
sl.no. | get() | navigate() |
---|---|---|
1 | It is responsible for loading the page and waits until the page has finished loading. | It is only responsible for redirecting the page and then returning immediately. |
2 | It cannot track the history of the browser. | It tracks the browser history and can perform back and forth in the browser. |
Example
With get().
import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; import java.util.List; public class LaunchBrw { public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe"); WebDriver driver = new ChromeDriver(); String url = "https://www.tutorialspoint.com/index.htm"; driver.get(url); driver.manage().timeouts().implicitlyWait(12, TimeUnit.SECONDS); driver.close(); } }
Example
With navigate().
import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; import java.util.List; public class BrowserNavigation { public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe"); WebDriver driver = new ChromeDriver(); String url = "https://www.tutorialspoint.com/index.htm"; // new browser will launch and navigate to the URL driver.navigate().to(url); driver.manage().timeouts().implicitlyWait(12, TimeUnit.SECONDS); // refresh the current browser driver.navigate().refresh(); //Using id tagname attribute combination for css expression driver.findElement(By.cssSelector("input[name=’search’]")). sendKeys("Selenium"); //browser will go back to the previous page driver.navigate().back(); //browser will go move to the next page driver.navigate().forward(); driver.close(); } }
- Related Articles
- What are the differences between paint() method and repaint() method in Java?
- What are the differences between printStackTrace() method and getMessage() method in Java?
- What are the differences between C++ and Java?
- What are the differences between C and Java?
- What are the differences between holography and photography?
- What are the differences between lodash and underscore?
- What are the differences between IPO and FPO?
- What are the differences between solvency and liquidity?
- What are the differences between Flutter and Xamarin?
- What are the differences between Fiber and Fabric?
- What are the differences between Minerals and Ores?
- What are the differences between fertilization and syngamy?
- What are the differences between coal and petroleum?
- What are the differences between patent and trademark?
- What are the differences between liquidation and bankruptcy?

Advertisements