What are the most basic steps to write a web driver script?

Software TestingAutomation TestingSelenium Web Driver

The most basic steps to write a web driver script are listed below −

  • Open any browser by creating a webdriver reference pointing to the corresponding browser driver class.

  • Launch any URL with the get() method.

  • Pause for some time for the page load.

  • Confirm that we are on the correct web page.

  • Finally close the session.

Code Implementation


import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
public class WebScripting {
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver",       "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      String url = "https://www.tutorialspoint.com/index.htm";
      // launching the URL
      driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
      System.out.println("Page loaded successfully");
Published on 10-Jun-2020 12:06:16