Java Demonstration Scripts


The demo scripts in this repository allow you to run simple automated tests in order to validate your Java Selenium environment and your account credentials.


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.

Some examples in this repository, such as appium-example, parallel-testing, and headless, may require a different account tier beyond free trial. Please contact the Sauce Labs Sales Team for support and information.

Solution Outline


Select the button below to try this demo in Gitpod

Click here to see how to setup your Sauce Labs credentials in Gitpod

Project Setup

Import the Project

  1. Create a directory on your machine.
  2. Clone this repository into said directory.
    $ git clone
  3. Import the project into your IntelliJ (or IDE of your choice) as a Maven Project.
  4. Click through the prompts, and confirm when it asks to Import from Sources
  5. Choose the demo-java directory as the root directory of the project.

Set Your Sauce Labs Credentials

  1. Copy your Sauce Labs username and accessKey in the User Settings section of the Sauce Labs Dashboard.

  2. Open a Terminal window (command prompt for Windows) and set your Sauce Labs Environment variables:

    Mac OSX:
    $ export SAUCE_USERNAME="username"
    $ export SAUCE_ACCESS_KEY="accessKey"
    > set SAUCE_USERNAME="username"
    > set SAUCE_ACCESS_KEY="accessKey"

    To set an environment variables permanently in Windows, you must append it to the PATH variable.

    Go to Control Panel > System > Windows version > Advanced System Settings > Environment Variables > System Variables > Edit > New

    Then set the "Name" and "Value" for each variable

  3. Test the environment variables

    Mac OSX:
    $ echo $SAUCE_USERNAME
    $ echo $SAUCE_ACCESS_KEY

    WARNING FOR UNIX USERS!: If you have problems setting your environment variables, run the following commands in your terminal:

    $ launchctl setenv SAUCE_USERNAME $SAUCE_USERNAME
    $ launchctl setenv SAUCE_ACCESS_KEY $SAUCE_ACCESS_KEY

Run a Maven Test

  1. Run the following command to update any package dependencies:
    $ mvn dependency:resolve
  2. Then run the following command to compile your test code:
    $ mvn test-compile
  3. Finally, run the following test to see if you've properly configured the test environment:

    $ mvn test -Dtest=Module2TestNGTest -pl on-boarding-modules/testng

    If you wish to run a specific test/sub-module in this emusim_testng use the following command:

      # for running a specific test:
      mvn test -Dtest=testname
      # for running a specific sub-module
      mvn test -pl subproject/