TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Selenium

Page Navigation in WebDriver

Introduction

In this article, we will discuss different page navigation used in WebDriver automation tests. Mostly, the important things that we do while authoring Selenium tests are Page navigation.

Some of the operations that we do are listed below:

  • Navigate between the pages that open during the tests.
  • Sometimes we would like to use the browser’s back and forward functionality.
  • We might want to refresh the current web page.

 

We will go through different kinds of navigation within Selenium tests.

To navigate to a webpage with a known URL. For example, if we want to navigate to the Bing search page.

driver.get(“https://www.bing.com/”);

OR

driver.navigate().to(“https://www.bing.com/”);

driver.get()

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.

Webdriver allows using the Navigation interface to access browser history. Navigation is an abstraction allowing the driver to access the browser’s history and to navigate to a given URL.

driver.navigate().forward();

Move a single “item” forward in the browser’s history. Also,does nothing if we are on the latest page viewed.Useful to go to the next page.If the next page exists, for example if you go back from a page, then want to return to it.

driver.navigate().back();

Move back a single “item” in the browser’s history.

driver.navigate().refresh();

To refresh the current page:

driver.navigate().to();

Loads a new web page in the current browser window. It uses an HTTP GET request operation, and the method will block until the load is complete.Also, this will follow redirects issued either by the server or as a meta-redirect for example 301 redirects from within the returned HTML.

to() method is overloaded in the Navigation interface. It has two signatures and allows String as well as URL as shown below:

void to(String url);

An overloaded version of that makes it easy to pass in a URL.

void to(URL url);

—

Selenium Tutorials on this website:

https://www.testingdocs.com/selenium-webdriver-tutorial/

Official Website:

https://www.selenium.dev/

Related Posts

Windows 10 Settings

Selenium /

Add Microsoft Webdriver on Windows OS

Download Selenium Components

Selenium /

Getting Started with Selenium Webdriver

LambdaTest Testing Cloud SaaS Platform

Selenium /

LambdaTest – Testing Cloud SaaS Platform

Selenium /

Selenium 3.0 and Mozilla GeckoDriver

SauceLabs Website

Selenium /

Run an Example Test on SauceLabs

‹ Selenium Tutorial: DesiredCapabilities› Selenium Test Customization

Recent Posts

  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version