Skip to main content

Selenium Quickstart

Get up and running quickly with your first Selenium WebDriver automated test on the Sauce Labs cloud.

  • Don't have Selenium tests, but want to try? Our examples below include sample project structures, Java tests, and working configuration specifications, so you can get up and running in less than 10 minutes using the instructions on this page!
  • Already have Selenium tests to run? Take advantage of the Sauce Labs cloud to test on thousands of desktop and mobile browser/OS combinations and maximize your digital confidence.

The examples below are written in Java and run Selenium web tests on a Chrome browser. You can use a CLI terminal or an IDE, such as IntelliJ Community Edition or Visual Studio Code. IDEs incorporate all of the tools needed for developing and running code text editor, terminal, debugging console, and more.

What You'll Need

Basic Selenium Test

This is a simple browser test that uses Selenium to navigate to our Sauce Labs demo site. The Selenium Quickstart Java Project contains all files and dependencies needed to execute a web app test.

Step 1: Clone Sample Project

  1. Go to your machine's home directory.
cd ~
  1. Clone the Selenium Quickstart Java Project.
git clone
  1. Go to the project.
cd quickstart-selenium-java

Step 2: Run Test

Run the following code to execute your test.

mvn test

Step 3: View Test Results

You should see a session confirmation message like this. Copy and paste the Test Job Link into your browser to see your test results on Sauce Labs.

Once you get to the Test Results page, click on your test to view its details.

Selenium WebDriver Tests

In this Selenium test, you'll automate WebDriver to open and close a Chrome browser window. For this section, you'll need an IDE, such as IntelliJ or Visual Studio Code.

Step 1: Clone Project

  1. Open VS Code and click Clone Git Repository.
  2. Enter the Sauce Labs Advanced Selenium Training Project URL ( and click Clone from URL.

Step 2: Download Dependencies

This quickstart test utilizes the Java Development Kit (JDK) (download here), which is required to compile and execute Java code, and Selenium Java bindings (download here), which are required for Selenium-Java compatibility.

Step 3: Import Dependencies

If it's your first time ever opening a Java project, follow the steps below; if not, you can skip this.

  1. Your IDE will prompt you to set up your JDK. You'll need to click on the prompt.
  2. Provide the location where you downloaded the JDK. Some IDEs will detect and find the path for you, so all you have to do is select it.

If you're new to IDEs, here are some tips:

OpenJDK distributions
IDEs also give you the option to download open source JDK distributions (e.g., Amazon Corretto, Oracle OpenJDK, and Eclipse Temurin) as an alternative to downloading JDK to your local machine. This works, but will only download it this specific project. If you're setting up a permanent developer environment that will be used beyond this Quickstart, you should download the JDK locally.
Extensions and plugins
If your IDE recommends additional extensions and plugins for Java and Maven, such as the ones listed below, you should accept them since they may contain more dependencies needed to run a test.

Step 4: Run Test

Right-click and run the test file,

Step 5: View Test Results

You should see a Chrome browser window pop up and then quickly close. Your results will show a confirmation that ChromeDriver started successfully.
Successful test results

This concludes the test! If you're feeling ambitious, proceed to the next section to try out some additional common Selenium commands.

Extra Credit (Optional)

In this exercise, you'll be running the same test, but with a few more actions this time. You'll automate WebDriver to open a Chrome browser window, navigate to our demo site, log in with a username and password, maximize the browser window, then close the browser window.

  1. Copy and paste the below code into the test file, overwriting the previous test.
package com.saucelabs.advancedselenium.saucedemo.tests;

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

public class Hello {

public static void main(String[] args) {
// Lets WebDriverManager handle drivers
// Starts session (opens browser)
RemoteWebDriver driver = new ChromeDriver();

// Opens browser with desired URL
// Inputs standard_user in username field.
// Inputs secret_sauce in password field

// Clicks the Login button

// maximizes browser window

// Closes browser

See Finder Methods to learn about locating id names and other webpage elements. 2. Save your changes. 3. Run revised test.

More Information