(Java) Shared Page Object between iOS/Android

Im curious to see how others are sharing page objects between Android and iOS applications.

What I mean is, my native mobile apps share the exact same UI layout, I want to share my test cases between both iOS and Android and switch between page objects depending on my properties field (iOS/Android)

You can use annotations for that.


I also use custom spring profiles to further differentiate between POs if there are flow differences (Abstract PO-> android/ios)

I’m using Spring as well
Do you have any smalle examples of using your abstract PO and decided which child to instanciate (android/ios)?

Currently I’m using prototypes to get my PO’s.
LoginPage lp = (LoginPage) ApplicationContextHolder.getBean(“loginPage”, driver);

public abstract class LoginPage {

WebElement loginSubmitButton;


public class ANDLoginPage extends LoginPage{
override submit button


public class IOSLoginPage extends{


I need that ApplicationContext holder to return my IOSloginPage if I’ve set the appium device to IOS.