In this post, I'm going to share the process behind my latest experimental work. The main idea is to run web tests from a mobile device. I'll proceed in iterations with the first step to determine if this approach is feasible.

My name is Abdallah Yashir Ramsing. I code programs for a living with the aim of learning, growing and sharing my experience with others.

Assumptions in our use case

As there already exists a mobile application for both Android and iOS, we assume that users will either use a desktop or a tablet to access the Web Application. And/or their phones for the app.

However, some users do access the web version on their mobile device. As this hasn't been initially expected, we therefore need to at least verify - if the web application loads well from a browser in a mobile phone.

Is it feasible?

The Automation tests are written in Java using Appium for the app and C# using Selenium for the Web. Before changing any code, I look for ways to test if the main hypothesis is true. The easier and quicker I can get feedback, the better. In this way, I avoid potential waste of time and effort.

To begin with, I research if this idea has already been covered by someone. I glance over a couple of articles to see if I'm on the right path. With ideas such as directly launching the browser from Appium glowing up, I try different desired capabilities, which are ways to configure a mobile browser for automation.

Using BrowserStack as a platform to run Android and iOS devices, I experiment with the capabilities to no avail, resulting in a wrong device or platform error. I meanwhile continue researching for any lead, including the official Appium documentation.

At first, nothing works but at least I get to refine keywords of what I am searching for. The more I read on the subject, the clearer it becomes in my mind. I am better able to distinguish between relevant pieces of information. The dot starts connecting.

Breakthrough

My breakthrough finally arrives with reading this article from TestSigma. With this settings, there is no error but a blank screen appears.

{
    "platformName": "Android",
    "device": "Samsung Galaxy S21 Ultra",
    "realMobile": true,
    "platformVersion": "11.0"
}
Blank Appium Screen

This small step gives me confidence to pursue further. I assume a configuration might be missing. I proceed in baby step with one change at a time.

{
    "platformName": "Android",
    "device": "Google Pixel 5",
    "realMobile": true,
    "platformVersion": "12.0",
    "AUTO_WEBVIEW": true,
    "browserName": "Browser"
}
Default Browser

With Chrome Browser:

Chrome Browser

The browser or browserName key is missing. Once added, I can at last load the browser. However, at this point, I don't know how to go to a specific URL using Appium Inspector. This might require a script.

I go back to the official documentation from BrowserStack, Appium and research through StackOverflow. My aim is to test this hypothesis: can I go to a custom URL? I pick up Python code snippets from the docs to create a simple script. This is much simpler for me than having to refactor the existing app automation project with Java just for testing an idea.

driver.get("https://google.com");

The test works. The mobile device browser is loaded with the URL.

Once done, I add the Web Application I want to test, login and assert if the title is the same. As usual with asynchronous tests, I add a wait until clause to make sure the application is loaded before doing anything else.

Refactoring

Copy pasting from my Python prototype, in the Java Automation Project, I add a new package, class and method for the Web Test. I also add a new driver method with the new desired capabilities separately. As the project uses testNg, I finally add a new file and run the test successfully.


If my articles help you and you want to support my work, you can buy me a coffee: