This directory contains example scripts and dependencies for the SauceCon workshop: Best Practices for Automated Testing. Use these scripts to test your Sauce Labs authentication credentials, setup your automated testing environment, try out Sauce Labs features, and complete the in-class Selenium examples. Download the zip file or clone the entire directory to your local environment.
The code in these scripts is provided on an "AS-IS” basis without warranty of any kind, either express or implied, including without limitation any implied warranties of condition, uninterrupted use, merchantability, fitness for a particular purpose, or non-infringement. These scripts are provided for educational and demonstration purposes only, and should not be used in production. Issues regarding these scripts should be submitted through GitHub. These scripts are maintained by the Technical Services team at Sauce Labs.
These procedures will show you to set up a Selenium environment for Java. The scripts in this repository allow you run a simple automated test to validate your Selenium environment and your saucelabs.com account credentials. In order to complete these exercises you must complete the following prerequisite installation and configuration steps:
- Install Git
- Install IntelliJ
- Install JDK
- Install Maven
- Setup Project
Once your test environment is up and running, refer to the exercise guides to begin the exercises.
Git is a version control system that lets you check out code from a repository, work with that code on your own branch, and then merge that code with any changes that have been made by other developers. Git is an essential tool for distributed development teams, and is a critical component of the continuous integration/continuous development toolchain.
- Go to https://git-scm.com/downloads.
- Under Downloads, click Mac OS X.
- When the download completes, double-click the
.dmg
file open the installer package. - Double-click the installer package to begin the installation.
Security Warning
You may see a warning message that the package can't be opened because it's not from a recognized developer. If this happens, go to System Preferences > Security and Privacy Settings, and click Open Anyway.
- Click Continue for the installation, and enter your local password to authorize the installation.
- Go to https://git-scm.com/downloads
- Under Downloads, click on Windows.
- When the dialog opens asking if you want to allow the app to make changes to your device, click Yes.
- Follow the steps in the setup wizard to complete the installation. You should accept all the default settings.
IntelliJ is an integrated development environment that incorporates several tools for developing and running Java code. You will be using IntelliJ to write and edit the sample Selenium scripts used in the exercises. For these exercises you only need to download the free Community edition.
- Go to https://www.jetbrains.com/idea/
- Click Download.
- On the Downloads page, select macOS.
- Under Community, click Download.
- When the download completes, double-click the .dmg file open the installer package.
- Double-click the installer package to begin the installation.
- Drag and drop the IntelliJ icon into the Applications folder.
- Go to https://www.jetbrains.com/idea/
- Click Download.
- On the Downloads page, select Windows.
- Under Community, click Download.
- When the download completes, double-click the
.exe
file to launch the installation wizard. You should accept all the default settings.
The Java SE Developer Kit lets you develop and deploy Java applications on desktops and servers. It is needed to compile our test code.
- Go to the JDK downloads page, locate the latest release, select the download button.
- Under Java SE Development Kit {version}, select the Accept License Agreement radio button.
- Click the download link for Mac OS.
- When the download completes, double-click the
.dmg
file open the installer package. Double-click the installer package to begin the installation.
- Go to the JDK downloads page, locate the latest release, select the download button.
- Under Java SE Development Kit {version}, select the Accept License Agreement radio button.
- Click the download link for Windows x64.
- When the download completes, double-click the
.exe
file open the installer package. - Double-click the installer package to begin the installation. You should accept all the default settings.
Maven is a build automation and project management tool use for managing project builds, dependencies, and documentation. It uses a project object model (pom.xml) to manage Java-based projects. With our use case, it's very useful for configuring and managing test suites.
-
Go to Maven Apache website and download the following package:
apache-maven-<version>-bin.tar.gz
-
Extract the archive
$ tar -xvf apache-maven-<version>-bin.zip
-
Add the
bin
directory of the extracted directory (apache-maven-<version>
) to thePATH
variable:$ export M2=$M2_HOME/bin $ export PATH=$M2:$JAVA_HOME/bin:$PATH
WARNING!: Make sure you've set
JAVA_HOME
othewisemvn
commands won't run -
Check to see if maven installed correctly:
$ mvn -version
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-24T11:41:47-07:00) Maven home: /usr/local/apache-maven-3.6.0 Java version: 11.0.2, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home Default locale: en_US, platform encoding: UTF-8 OS name: "mac os x", version: "10.13.6", arch: "x86_64", family: "mac"
- Go to Maven Apache website and download the following package:
apache-maven-<version>-bin.zip
- Unpack the archive using an archive tool (for example WinZip)
- Add the unpacked distribution’s
bin
directory to your userPATH
environment variable by:- Open up the system properties (WinKey + Pause)
- Select the Advanced tab, and the Environment Variables button
- Add/Select the
PATH
variable in the user variables with the value:C:\Program Files\apache-maven-3.6.0\bin
- Open a new command prompt (Winkey + R then type cmd) and run
mvn -v
to verify the installation.
- Import the project into IntelliJ as a Maven Project.
- Click through the prompts, and confirm when it asks to Import from Sources
- Open a terminal and run the following command to update any package dependencies:
$ mvn dependency:resolve
- Then run the following command:
$ mvn test