Why Sauce Labs Testing?
We are going to utilize Sauce Labs for testing the Mobile Application under the cloud testing infrastructure. It will help us to ensure the device coverage in mobile application testing including the device interoperability. Test Results will be published with the detailed logs,screenshots, reports, Video and meta data. Mobile Application Automation Testing can be implemented by using the open testing framework of Appium with Junit in Eclipse IDE.
We will be using our mobile application Fontli in the Sauce Labs and it will be automated by using both the web/mobile element specific testing of Appium+Junit+Java as a proof of concept. Open Test Framework Appium will support Acceptance Testing.
We have created a test script using Java as a programming language integrated with Junit to automate a login process of Fontli Mobile Application. Open Test Framework Appium JAR has been integrated with the Eclipse IDE.
How Appium works?
Appium is going to work with the Node Server concept in which Test Script event request pushed to the Node server and the same server again push the JSON request to the real device or emulator connected with the machine. Appium Node server will take the control of ADB(Android Device Bridge) in full swing to trigger all the Test Script events. Once run the Test Script under the Junit Run Configuration, test cases will be executed and results has been published in the Eclipse IDE.
We need to mention about the desired capabilities of test device and mobile app(apk) which is a key factor to start testing the mobile application in Sauce Labs. Now come to the Sauce Labs Automated Mobile Testing Infrastructure, we need to upload the Fontli
application package(APK) in Sauce Storage. Sauce Storage lets you securely store apps for use in your tests. Files are uploaded and stored in the internal network, and access is restricted to users in account hierarchy. They stick around for seven days and are then
deleted.
How to upload APK file in Sauce Labs?
APK upload will be done based on the below command and the same sauce labs wiki link has been shared below for future reference;
curl u
<sauce_username>:<sauce_access_key> X POST -H “ContentType: application/octetstream”
https://saucelabs.com/rest/v1/storage/<sauce_username>/<upload_filename>?overwrite=true databinary @/<path/to/your_file_name>
Reference URL: https://wiki.saucelabs.com/display/DOCS/Using+Sauce+Storage+for+Test+Assets
How Platform configurator works?
Once the file upload completed based on the above information, you need to get the desired capabilities specific to the device, operating system, appium version, app type in accordance with the below screenshot and URL;
Reference URL: https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/
The platform configurator will generate desired capabilities(which will be mentioned in the Eclipse IDE scripting part) once the user selection/input got selected specific to the testing requirement;
DesiredCapabilities caps = DesiredCapabilities.android(); caps.setCapability(“appiumVersion”, “1.4.16”);
caps.setCapability(“deviceName”,”LG Nexus 4 Emulator”); caps.setCapability(“deviceOrientation”, “portrait”);
caps.setCapability(“browserName”, “”); caps.setCapability(“platformVersion”,”4.4″); caps.setCapability(“platformName”,”Android”);
caps.setCapability(“app”,”saucestorage:testapp.apk”);
How Appium Works on Sauce Labs?
The driver address in you test script is what points the test to the Sauce Labs cloud, for example http://SAUCE_USERNAME:SAUCE_ACCESS_KEY@ondemand.saucelabs.com:80/wd/hub.
Once you execute the test using the test framework of your choice, Sauce Labs initializes its own Appium server using the specifications taken from your desired capabilities.
What happens after that depends on the type of mobile platform you’re testing against.
driver = new AndroidDriver(new URL(“http://gopikannan:85678f724d0145c9895b39ee8b2f8ce1@
ondemand.saucelabs.com:80/wd/hub”), caps);
After the mobile application is initialized, the Appium server receives your test script commands and launches your mobile application in the emulator/device that you’ve specified. Appium then takes the driver commands in your test script, which are in a WebDriver JSON Wire Protocol format, and converts them into UIAutomator Java commands. UIAutomator is the library provided by Google as part of the Android SDK, and is also the library that Appium uses to automate your Android mobile application tests. In the case where you are connecting to the Selendroid automation backend, Appium simply proxies all requests to the Selendroid server running on the emulator/device.
The response from your mobile application are received by UIAutomator and relayed to the Appium server in the Sauce Labs cloud. The Appium server then converts the UIAutomator Java responses back into WebDriver JSON Wire Protocol format, and send the JSON
responses back to your test script. Appium hides all of this complexity from your test script. Your test script thinks it’s communicating with your mobile application, but in reality it is communicating with Appium’s implementation of the WebDriver API. The fact that Appium is running your mobile application in the appropriate simulator, emulator or device, and wrapping up all of the communications with your mobile application, including the command conversions, remains completely hidden, and your test script is none the wiser.
You could run the test script from the Eclipse IDE by mapping the Sauce Labs server details in the driver address script. Once test runj completed, you could visualize the test reports under the Sauce Labs Dashboard which is created for your unique login account.
Please refer the below screenshot for detailed understanding;