Mobile automated testing using Appium and Java
- What is Appium
- Create an automated Android test
- Find element locators using Appium Inspector
- Run tests in Sauce Labs real devices
- 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.
- Please install appium inspector. Appium Inspector is basically just an Appium client (like WebdriverIO, Appium's Java client, etc...) with a user interface.
- The demo app that has been used for all these 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.
In the browser address bar, add your GitHub url (https://github.com/USERNAME/this-repo-name
)
- Once the 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 sanity tests
mvn clean test -DtestngXmlFile=myDemoTests.xml
Click here to see an example console output.
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running TestSuite
*** BeforeMethod hook. Running method demoTest ***
region is us
*** Start demoTest test ***
*** AfterMethod hook ***
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.488 s - in TestSuite
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.579 s
[INFO] Finished at: 2022-07-04T12:05:35+01:00
[INFO] ------------------------------------------------------------------------
# --- ### Local environment setup
- 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
Setup environment variables on your system