Java Demonstration Scripts
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.
🥇 Most Popular
- Web automation best practices framework with multiple testing strategies. Crafted by industry experts with decades of experience.
- Quick start test, Junit 5
- Quick start test, Junit 4
- Quick start test, TestNg
- iOS real device, native app, Junit4
- Front-end performance testing
- Visual E2E test
- Sauce Connect usage
Best Practices
- Desktop
junit4
sauce-bindings
- Emu/Sim Web
junit4
sauce-bindings
- Performance
junit4
sauce-bindings
- RealDevice
junit4
sauce-bindings
- Visual E2E
junit4
sauce-bindings
🖥 Web automation
-
Sauce Bindings With TestRunner Examples
-
Sauce Bindings Examples
-
Selenium Examples
- Accessibility Test with Sauce Bindings
junit4
sauce-bindings
- Accessibility Test with Deque Axe
junit4
- Cucumber web test
- Windows authentication
junit4
- Cross Browser/Platform in Parallel w/ TestNG
testng
- Performance, front-end with Sauce Bindings
junit5
sauce-bindings
- Single Browser in Parallel w/ TestNG
testng
- Visual e2e test
visual
junit4
- Visual e2e test with branching strategy
visual
junit4
- Accessibility Test with Sauce Bindings
📱 Mobile automation
-
Real Devices
-
Emulators and Simulators
⚙️ Setup
- Install Git
- Install IntelliJ (or another IDE)
- Install JDK
- Install Maven
Import the Project
-
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.
Set Your Sauce Labs Credentials
-
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:
Mac OSX:$ export SAUCE_USERNAME="your username" $ export SAUCE_ACCESS_KEY="your accessKey" $ export SCREENER_API_KEY="your screener key"
Windows:
> set SAUCE_USERNAME="username" > set SAUCE_ACCESS_KEY="accessKey" > set SCREENER_API_KEY="your screener key"
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
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
Windows:
> echo %SAUCE_USERNAME% > echo %SAUCE_ACCESS_KEY%
Run a Maven Test
-
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 -pl best-practice -Dtest=DesktopTests
You can run different tests from different modules. Check out some examples by looking at the CI YML files
Contributing
This repository is maintained by the Solutions Architect team at Sauce Labs. We welcome all ideas and contributions!
Guidance for contributing can be found here
Disclaimer
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.