- Free Sauce account
- Make sure you know how to find your Sauce Labs Username and Access Key by going to the Sauce Labs user settings page
- We will run our automated tests on Sauce Labs devices; therefore, there is no need to install Appium Server.
- The Android demo apps that has been used for the Android tests can be found here.
- The iOS demo apps that has been used for the iOS tests can be found here.
Be aware of the fact that and iOS simulator uses a different build then a iOS real device. So please check the file you download.
The advice is to download the files to an
apps
folder in the root of this folder.
Make sure that when you downloaded the files from the releases page, that you rename the apps to the following:
mda-{#.#.#-#}.apk
=>my-demo-app-android.apk
SauceLabs-Demo-App.ipa
=>SauceLabs-Demo-App.ipa
Saucelabs-demo-app.simulator.zip
=>SauceLabs-Demo-App.Simulator.zip
If you don't do that then the scripts can't find the apps!
If you want to use Android emulators, Android real devices, iOS simulators or iOS real devices in the Sauce Labs platform, you need to upload the apps to the Sauce Storage.
Execute the following steps to manually upload the apps:
- Login to the Sauce Labs platform
- Go to LIVE > Mobile App
- Click on App Upload and OR select the folder, OR drag the apps to the screen to upload them
You can find a script to upload them to, OR the US, OR EU DC in this-file. You can push the files to the
storage by doing the following from the folder appium-app-examples
:
cd src/test/java/sauce/demo/helpers/
./push_apps_to_storage.sh
ℹ Gitpod lets you run an entire Dev environment from a browser! You can use this approach if you don't have time or you don't know how to setup a local Java environment.
- Sign up for a free GitHub account
- Fork this repository
- Make sure you are logged into GitHub
- Click the Fork in the upper right of the GitHub.
- Give the repo a ⭐ while you're here 🤩
3.In the browser address bar, add your GitHub url (
https://github.com/USERNAME/this-repo-name
) withhttps://gitpod.io/#
-
The resulting url should look as follows:
https://gitpod.io/#https://github.com/USERNAME/sauce-java-appium-cross-platform
-
- Once the Gitpod.io URL is loaded, you will need to sign in with the GitHub account you created earlier
- Once the development environment is loaded, you should see 'Ready to test!' in the Terminal window in the lower portion of the window, run the following commands in that Terminal to set your
SAUCE_USERNAME
,SAUCE_ACCESS_KEY
:
eval $(gp env -e SAUCE_USERNAME=<sauce_username>)
eval $(gp env -e SAUCE_ACCESS_KEY=<sauce_access_key>)
Replace <sauce_username>, <sauce_access_key> with your credentials
Once you have run those 2 commands, you can run the following commands to test your environment variables:
echo $SAUCE_USERNAME
echo $SAUCE_ACCESS_KEY
Run the tests
// If using the US DC
mvn clean test -Dregion=us
// If using the EU DC
mvn clean test -Dregion=eu
Click here to see an example console output.
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running TestSuite
Sauce Android Native App - Before hook
*** BeforeMethod hook. Running method addProductToCart ***
Sauce Android Native App - Before hook
*** BeforeMethod hook. Running method addProductToCart ***
region is eu
region is eu
region is eu
region is eu
Sauce - Start selectProduct test
Sauce - Start selectProduct test
Sauce - AfterMethod hook
Sauce - AfterMethod hook
Sauce - Start selectProduct test
Sauce - release driver
Sauce - Start selectProduct test
Sauce - AfterMethod hook
Sauce - release driver
Sauce - AfterMethod hook
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 31.102 s - in TestSuite
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0
[INFO]
mobile_workshop_prep.mp4
- Sign up for a free GitHub account
- Fork this repository
- Make sure you are logged into GitHub
- Click the Fork in the upper right of the GitHub.
- Give the repo a ⭐ while you're here 🤩
- Clone your fork of the repository to your machine. Must have Git installed
git clone URL_OF_YOUR_FORK
Setup environment variables on your system
Run the tests
// If using the US DC
mvn clean test -Dregion=us
// If using the EU DC
mvn clean test -Dregion=eu
Click here to see an example console output.
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running TestSuite
Sauce Android Native App - Before hook
*** BeforeMethod hook. Running method addProductToCart ***
Sauce Android Native App - Before hook
*** BeforeMethod hook. Running method addProductToCart ***
region is eu
region is eu
region is eu
region is eu
Sauce - Start selectProduct test
Sauce - Start selectProduct test
Sauce - AfterMethod hook
Sauce - AfterMethod hook
Sauce - Start selectProduct test
Sauce - release driver
Sauce - Start selectProduct test
Sauce - AfterMethod hook
Sauce - release driver
Sauce - AfterMethod hook
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 31.102 s - in TestSuite
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0
[INFO]
You can run the Appium tests directly from GitHub using GitHub Actions
- Add two new variables: SAUCE_USERNAME and SAUCE_ACCESS_KEY to your GitHub Repository Secret, as shown in the snapshot
More info can be found here.
2. Select (1) Actions tab -> (2) Click on "Real Devices" (3) Click "Run workflow" and (4) Run workflow
3. GitHub Actions starts to run
4. You should see four test executions running in Sauce Labs platform
5. Wait till the tests passed
You can run the Appium tests using SO directly from GitHub using GitHub Actions
-
Add two new variables: SAUCE_USERNAME and SAUCE_ACCESS_KEY to your GitHub Repository Secret, as shown in the snapshot
-
Add also the two variables: DOCKERHUB_USERNAME and DOCKERHUB_TOKEN to your GitHub Repository Secret with your Docker username and password.
More info can be found here.
-
Select (1) Actions tab -> (2) Click on "native app workflow using ImageRunner" (3) Click "Run workflow" and (4) Run workflow
- Run the tests locally by using the command:
mvn clean test
- Make sure tests run as expected.
- Check docker is up and running by using the command:
docker info
- Create the docker file
- build the image from the docker file
// The format
$ docker build -t <docker username>/<project-name>-<container-name>:<tag> <path-to-dockerfile>
// Example
$ docker build -t eyalyovelsauce/sauce-java-appium-cross-platform-docker:0.0.1 .
$ docker run --rm -e SAUCE_USERNAME=${SAUCE_USERNAME} -e SAUCE_ACCESS_KEY=${SAUCE_ACCESS_KEY} eyalyovelsauce/sauce-java-appium-cross-platform-docker:0.0.1
- Push Image to a Docker Registry
$ docker login
$ docker push eyalyovelsauce/sauce-java-appium-cross-platform-docker:0.0.1
$ saucectl run
The saucectl config file is here