Skip to content

saucelabs-training/demo-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java Demonstration Scripts

Welcome to Java Demo Scripts, a set of examples showing how to use the features of Sauce Labs. This repository contains everything you need to start with web, mobile, functional, and all other types of Java automation.

PRs Welcome

Best Practices Tests

JUnit 5 Tests

JUnit 4 Tests

TestNG Tests

Cucumber Tests

Appium Examples - Real Devices

🥇Most Popular

Best Practices

🖥Web automation

📱Mobile automation

📚 Mobile Testing Training Tutorials

⚙️Setup/Prerequisites

  • git
  • JDK (11 or later)
  • Maven
  • IntelliJ, VS Code, or another IDE
  • Sauce Labs account, with Username and Access Key

Import the Project

  1. Create a directory on your machine.

  2. Clone this repository into the said directory.

    $ git clone https://github.com/saucelabs-training/demo-java.git
    
  3. Import the project into your IDE. The project is a collection of Java modules, so be sure to enable the module you're interested in within the IDE (to allow Maven to recognize it properly).

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="your username"
    $ export SAUCE_ACCESS_KEY="your accessKey"
    

    To set an environment variable permanently in MacOS, you must set it within your chosen shell's profile config.

    Windows:

    > set SAUCE_USERNAME="username"
    > set SAUCE_ACCESS_KEY="accessKey"
    

    To set an environment variable permanently in Windows, you must set it within System Properties.

    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
    

    Windows:

    > echo %SAUCE_USERNAME%
    > echo %SAUCE_ACCESS_KEY%
    

Run a Maven Test

  1. Go to the chosen module where you'd like to do your testing (these examples will use best-practice)

    $ cd best-practice
    
  2. Run the following command to update any package dependencies:

    $ mvn dependency:resolve
    
  3. Then run the following command to compile your test code:

    $ mvn test-compile
    
  4. Finally, run the following test to see if you've properly configured the test environment:

    $ mvn test -Dtest=DesktopTests
    

    You can run different tests from different modules. Check out some examples by looking at the CI YML files

Contributing

Sauce Labs maintains this repository. 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 require an account tier beyond the free trial. Please contact the Sauce Labs Sales Team for support and information.

About

A repository containing examples using Java with Sauce Labs

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Languages