Page Object model with Appium

In this post we will discuss how to create and work with Page Object Model (POM) in Appium. We have already discuss page POM in greater detail while discussion Selenium framework design and development articles and videos, hence we will change our gears here to focus directly on the coding part of Page Object Model in appium rather talking about its theories.

Here is the complete code for Page Object Model (POM) in appium

Code for Page

Code for Test 

Here is the complete video of the above discussion

Thanks for reading the post and watching the video !!!

Please leave your comments and let me know if there is anything I should update in this post.

Karthik KK


  1. Labha Bissa says:

    Nice and very helpful tutorials… Please add some more videos for automation selenium code on Android and iOS native apps using appium together.

    Thanks a lot Karthik…

  2. Sudheendran P L says:

    Very Helpful. Thanks a lot. Can you please share some more videos considering complex android native / hybrid applications.

  3. Jean says:

    Thank you, POM seems an interesting framework.
    Too bad we can’t use variables in AndroidFindBy with xpath to have dynamics object.
    Like getting the x textfield, or to get the textfield with the text “xxx”. Constants only are allowed.

  4. sushma says:

    I have implement POM with Appium in java. My code structure follows as below :
    page object classes : LoginPageObjectRepo() and HomePageObjectRepo()
    testng classes : RegisterAndLoginTCs() and HomePageTCs()

    RegisterAndLoginTCs() :
    public void setup() throws Exception{
    //initial setup and capabilities

    public void stopServer() throws IOException{

    public void TC1_login() throws Exception{
    LoginPageObjectRepo objDriver = new LoginPageObjectRepo(driver);
    WebDriverWait wait = new WebDriverWait(driver,300);
    By.xpath(“//*[@text=’Login successful’]”))));“User log in successfull”);

    }catch(Exception e){
    log.error(“User log in failed”);

    //other many test methods

    HomePageTCs :
    AndroidDriver driver;
    public void TC5_HomePageFormat() throws Exception{
    HomePageObjectRepo objdriver = new HomePageObjectRepo(driver);


    Now when i run this project i get nullpointer exception at HomePageTCs.TC5_HomePageFormat( ie. at line objdriver.SearchOption().click();

    I feel it is because driver is defined in RegisterAndLoginTCs class.
    How can i get access to same driver which is defined in setup() method so that once driver is defined with required capabilities, it can be used across multiple testng classes.

Leave a Reply

Your email address will not be published. Required fields are marked *