Gaurav
Gaurav

Reputation: 197

How to manage mobile automation for different devices?

I am working for a Mobile application automation. For all devices OS and manufacturer vise UI are different . eg. Date and Time picker.

How can one manage a mobile application automation?

Upvotes: 1

Views: 107

Answers (1)

Anish Pillai
Anish Pillai

Reputation: 1023

First of all, you need to figure out if same code is being used to develop mobile app for different platforms. For example, there are some cross platform software which can be used to write code which will work on both iOS and Android. In such a scenario, the underlying properties of the different controls in the app would be same. This would allow you to write same scripts that work on both Android and iOS.

You can use Page Factory Model and use @AndroidFindby and @iOSFindBy to identify on different platforms and refer it with a single variable.

Example -

@AndroidFindBy(uiAutomator="new UiSelector().text(\"Login\")")
@iOSFindBy(xpath="//UIAStaticText[@name='Login']")
private WebElement loginButton;

public void clickOnLoginButton() {
    loginButton.click();
}

clickOnLoginButton() method in the above code would work for both Android and iOS. Regarding things like Date and Time picker, which differ based on OS, you would need to tackle it with if conditions.

More that 80% of the scripts can work on both the devices without any changes. For the remaining, you might need to add if conditions, or write separate scripts.

Upvotes: 1

Related Questions