logo image

Sample selenium test scripts for navigating an application

In this tutorial, I explain how to write webdriver test script for navigating an application. Let us try to create a WebDriver script that would:

  1. Open Google application
  2. Clicks on "Sign in"
  3. Navigating (Back & Forward)
  4. Refresh

WebDriver Script:

package com.selenium.practise;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class GoogleNavigation {

	public static void main(String[] args) {
		System.setProperty("webdriver.chrome.driver", "E:\\Soft Wares\\chromedriver.exe");
		// Set path created for ChromeDriver 
		WebDriver driver = new ChromeDriver();
		// -> Here we are using ChromeDriver. 
		// -> ChromeDriver() object created and assigned object to WebDriver interface
		WebDriver.Navigation move = driver.navigate();
		// navigate() allows the driver navigate to URL and access the browser's history
		// WebDriver.Navigation is interface
		// Get Google application
		// clicking on Sign in
		// moves forward to Sign in page

		// moves back to Google main page

		// refresh current page
		// close application

		System.out.println("Navigation is success");