Is it possible? Both the apps have different element details. Can this be fixed from dev team?
It is possible by using the Page Object model and PageFactory
utility class. While describing your screens as page objects, you can specify different locators per platform. For example:
public class LoginView extends BaseView {
@AndroidFindBy(id = "email")
@iOSXCUITFindBy(accessibility = "email")
private MobileElement emailInput;
@AndroidFindBy(id = "password")
@iOSXCUITFindBy(accessibility = "password")
private MobileElement passwordInput;
@AndroidFindBy(id = "submit")
@iOSXCUITFindBy(accessibility = "submit")
private MobileElement submitButton;
public LoginView(AppiumDriver driver) {
super(driver);
}
public void login(String username, String password) {
emailInput.click();
emailInput.type(username);
passwordInput.click();
passwordInput.type(password);
submitButton.click();
}
}
In BaseView you need to pass driver instance and initialize elements, e.g. this way:
abstract class BaseView {
protected AppiumDriver driver;
public BaseView(AppiumDriver driver) {
this.driver = driver;
PageFactory.initElements(driver, this);
}
}
Now, you only need to grab locators for your elements on different platforms, all the rest will be handled by PageFactory.
Hope this helps