Welcome to Java Demo Scripts designed by Solution Architects to provide examples of how to use Sauce Labs technologies. This repository contains everything that you need to get started with web, mobile, visual, functional and all other types of automation using Java.
- Web automation best practices framework with multiple testing strategies. Crafted by industry experts with decades of experience.
- Quick start test, Junit 4
- Quick start test, TestNg
- W3C examples using Sauce Labs
- iOS real device, native app, Junit4
- Front-end performance testing
- Visual E2E test
- Sauce Connect usage
-
Popular Examples
-
Automation Best Practices
📚 Mobile Testing Training Tutorials
-
Popular Examples
-
Real Devices
-
Emulators and Simulators
-
-
Automation Best Practices
-
All Examples
- Install Git
- Install IntelliJ (or another IDE)
- Install JDK
- Install Maven
Select the button below to try this demo in Gitpod
Click here to see how to setup your Sauce Labs credentials in Gitpod
- Create a directory on your machine.
- Clone this repository into said directory.
$ git clone https://github.com/saucelabs-training/demo-java.git
- Import the project into your IntelliJ (or IDE of your choice) as a Maven Project.
- Click through the prompts, and confirm when it asks to Import from Sources
- Choose the demo-java directory as the root directory of the project.
-
Copy your Sauce Labs username and accessKey in the User Settings section of the Sauce Labs Dashboard.
-
Open a Terminal window (command prompt for Windows) and set your Sauce Labs Environment variables:
$ 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
-
Test the environment variables
$ 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
> echo %SAUCE_USERNAME% > echo %SAUCE_ACCESS_KEY%
-
Run the following command to update any package dependencies:
$ mvn dependency:resolve
-
Then run the following command to compile your test code:
$ mvn test-compile
-
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/
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
, andheadless
, may require a different account tier beyond free trial. Please contact the Sauce Labs Sales Team for support and information.