Selenium WebDriver - First Automation Script which covers all basic commands

This post will show you how to write your first Selenium Webdriver script. It will cover some of the very basic Webdriver commands. It covers following web actions and commands for same:
  1. Launch browser.
  2. Open demo url.
  3. Enter value in some text fields.
  4. Select Radio box.
  5. Select Checkbox.
  6. Click on Submit button
public class FirstWebdriverScript {

public static void main(String[] args) {

// Initialize Webdriver Object
System.setProperty("", "D:\\mydir\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
String browserUrl = "";
String firstName = "Mark";

// Opening Browser URL and Maximize Window

// Page Elements or locators
WebElement FIRST_NAME_FIELD = driver.findElement("firstname"));
WebElement RADIO_BUTTON = driver.findElement("sex-1"));
WebElement PROFESSION = driver.findElement("profession"));
WebElement SUBMIT_BUTTON = driver.findElement("submit"));

// Clear pre-values in textfield

// Enter Text

// Select Radio Button;

// Select Profession;

// Click on Submit Button;

// Close browser



Form Commands (Click, Enter Text etc.)  << Previous     ||     Next >>  Handle Links

Refer: Selenium Webdriver Tutorials Series

Join Telegram channel at
Feel free to ask queries or share your thoughts in comments or email me.


Popular Posts

Top 10 Demo Websites to Practice Selenium Webdriver Online

How To Handle Dynamic Xpaths (Web Table) in Selenium WebDriver

How to Take Screenshot and Partial Screenshot in Selenium WebDriver

Selenium WebDriver - Browser and Navigation Commands

Automation Framework Building 1st step - Implementing Code Re-usablility