{{announcement.body}}
{{announcement.title}}
Refcard #067

Getting Started With Selenium

A Portable Software Testing Framework for Web Applications

Covers the latest updates to Selenium and gives you the tools you need to launch Selenium on any major browser, on any major operating system.

45.5k
Free .PDF for easy Reference

Written by

Marcus Merrell Director of Technical Services, Sauce Labs, inc
Dave Haeffner Author, Elemental Selenium
Refcard #067

Getting Started With Selenium

A Portable Software Testing Framework for Web Applications

Covers the latest updates to Selenium and gives you the tools you need to launch Selenium on any major browser, on any major operating system.

45.5k
Free .PDF for easy Reference

Written by

Marcus Merrell Director of Technical Services, Sauce Labs, inc
Dave Haeffner Author, Elemental Selenium
Table of Contents

What Is Selenium?

Getting Started

Section 1

What Is Selenium?

Selenium is a free and open-source browser automation library used by millions of people for testing purposes as well as automation of repetitive web-based administrative tasks. It has the support of the largest browser vendors who have taken (or are currently taking) steps to make Selenium a native part of their browser. It is also the core technology in countless other browser automation tools, APIs and frameworks.

It is effectively the de facto standard for automating web browsers. WebDriver (the API to automate browsers, maintained by the Selenium project) is currently going through a W3C (World Wide Web Consortium) specification. Once the specification becomes ratified, Selenium will become the official standard for automating web browsers.

Section 2

Getting Started

There are Selenium language bindings for multiple programming languages. The officially supported ones (in order of use) are:

  • Java
  • JavaScript
  • Python
  • Ruby
  • C#

In order to start writing tests you, first need to install the bindings for your preferred programming language.

Java (With Maven)

In your test project, add the following to your pom.xml. Once done, you can either let your IDE (Integrated Development Environment) use Maven to import the dependencies or open a command-prompt, cd into the project directory, and run mvn clean test-compile.

<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>LATEST</version>
    <scope>test</scope>
</dependency>

Note: You will need to have the Java Development Kit (version 7+, or 8+ for 3.x versions of Selenium) and Maven installed on your machine. For more information on the Selenium Java bindings, check out the API documentation.

JavaScript (npm)

Type the following command into a command-prompt to install the JavaScript bindings for Selenium.

npm install selenium-webdriver

Note: You will need to have Node.js and NPM installed on your machine. For more information about the Selenium JavaScript bindings, check out the API documentation.

Python

Type the following command to install the Python bindings for Selenium.

pip install selenium

Note: You will need to install Python, pip, and setuptools in order for this to work properly. For more information on the Selenium Python bindings, check out the API documentation.

Ruby

Type the following command to install the Selenium Ruby bindings.

gem install selenium-webdriver

Note: You will need to install a current version of Ruby which comes with RubyGems. You can find instructions for that on the Ruby project website. For more information on the Selenium Ruby bindings, check out the API documentation.

C# (With NuGet)

Use the following commands from the Package Manager Console window in Visual Studio to install the Selenium C# bindings.

Install-Package Selenium.WebDriver
Install-Package Selenium.Support

Note: You will need to install Microsoft Visual Studio and NuGet to install these libraries and build your project. For more information on the Selenium C# bindings, check out the API documentation.

Note: The remaining examples will show Java demonstrations.

This is a sample of the Getting Started with Selenium Refcard. Please download the full PDF document from the link above. 

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}