Hey Amanprit, Navigation Commands are used to navigate through the web browser on a webpage. By using these commands, you can go Forward or Backward on a Webpage. You can also refresh a webpage. Following sample test script shows how navigation commands can be used:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Navigation_Commands {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.gecko.driver", "D:\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("https://www.edureka.co/");
driver.navigate().to("https://www.edureka.co/all-courses");
Thread.sleep(5000);
driver.navigate().back();
Thread.sleep(5000);
driver.navigate().forward();
Thread.sleep(5000);
driver.navigate().refresh();
}
}