Navigation Methods in Selenium WebDriver | To, Refresh, Back and Forward |
H Y R Tutorials H Y R Tutorials
63.7K subscribers
22,445 views
272

 Published On Apr 11, 2020

In this video, I have explained about Navigation Methods in Selenium WebDriver.

Selenium WebDriver is an open-source tool for automated testing of web apps across many browsers.

Selenium Webdriver Navigation is a very important part of Webdriver API and in this video, I have explained the navigation methods in detail.

Selenium WebDriver has provided 4 navigation methods, Those are as follows:
βœ” To
βœ” Refresh
βœ” Back
βœ” Forward

These 4 navigation methods are available under navigation class and this navigation class instance is available under WebDriver.
1) To
Load a new web page in the current browser window. This is done using an HTTP GET operation, and the method will block until the load is complete. This will follow redirects issued either by the server or as a meta-redirect from within the returned HTML. Should a meta-redirect "rest" for any duration of time, it is best to wait until this timeout is over, since should the underlying page change whilst your test is executing the results of future calls against this interface will be against the freshly loaded page.
Eg:
driver.navigate().to("https://facebook.com");

2) Refresh
Refresh the current page
Eg:
driver.navigate().refresh();

3) Back
Move back a single "item" in the browser's history.
Eg:
driver.navigate().back();

4) Forward
Move a single "item" forward in the browser's history. It does nothing if we are on the latest page viewed.
Eg:
driver.navigate().forward();

-- Webdriver Navigation Methods Example: ---
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import io.github.bonigarcia.wdm.WebDriverManager;

public class NavigationalMethods {
public static void main(String[] args) throws Exception {
WebDriverManager.chromedriver().setup();
WebDriver driver = new ChromeDriver();
driver.get("https://www.google.com/");
driver.findElement(By.name("q")).sendKeys("hyr tutorials");
driver.findElement(By.name("btnK")).submit();
driver.navigate().to("https://facebook.com");
driver.findElement(By.name("firstname")).sendKeys("Yadagiri");
driver.navigate().refresh();
Thread.sleep(2000);
driver.navigate().back();
Thread.sleep(2000);
driver.navigate().forward();
}
}

==============================================
************* Checkout my other playlists *************
==============================================
Java Programming videos playlist:πŸ‘‡
πŸ”— https://bit.ly/3keRJGa

Selenium WebDriver with Java videos playlist:πŸ‘‡
πŸ”— https://bit.ly/2FyKvxj

Selenium interview questions videos playlist:πŸ‘‡
πŸ”— https://bit.ly/3matUB3

Windows automation with FlaUI videos playlist:πŸ‘‡
πŸ”— https://bit.ly/33CG4dB

CSS Selectors videos playlist:πŸ‘‡
πŸ”— https://bit.ly/2Rn0IbD

XPath videos playlist:πŸ‘‡
πŸ”— https://bit.ly/2RlLdkw

Javascript Executor videos playlist:πŸ‘‡
πŸ”— https://bit.ly/2FhNXwS

Apache POI videos playlist:πŸ‘‡
πŸ”— https://bit.ly/2RrngrH

Maven videos playlist:πŸ‘‡
πŸ”— https://bit.ly/2DYfYZE

How to fix Eclipse errors:πŸ‘‡
πŸ”— https://bit.ly/3ipvNYf
==============================================
==============================================
Connect us @
πŸ”— Website - www.hyrtutorials.com
πŸ”— Facebook - www.facebook.com/HYRTutorials
πŸ”— LinkedIn - www.linkedin.com/company/hyrtutorials
πŸ”— Twitter - www.twitter.com/Hyrtutorials
==============================================
==============================================
πŸ™ Please SubscribeπŸ”” to start learning for FREE now, Also help your friends in learning the best by suggesting this channel.

#selenium #navigation #to #refresh #forward #back #hyrtutorials #webAutomation

show more

Share/Embed