Can anyone demonstrate how navigation commands can be used on a webpage in Selenium?

0 votes
Can anyone demonstrate how navigation commands can be used on a webpage in Selenium?
Jul 4 in Selenium by Amanprit
32 views

1 answer to this question.

0 votes

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.flipkart.com/");

        driver.navigate().to("https://www.flipkart.com/account/login");

        Thread.sleep(5000);
        driver.navigate().back();

        Thread.sleep(5000);
        driver.navigate().forward();

        Thread.sleep(5000);
        driver.navigate().refresh();
    }
}
answered Jul 4 by Anvi
• 13,960 points

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,110 points
993 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
1,144 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
889 views
0 votes
1 answer

How selenium can be used in devops lifecycle?

Hey Catherine, as we know that a ...READ MORE

answered May 8 in Selenium by Anvi
• 13,960 points
58 views