1

I am using Winapp Driver to control a windows desktop application using java. The automation runs fine but I am looking for a way to implement the Page object model. This is what I am using at the moment.

  • Appium
  • Winapp
  • Driver
  • Selenium TestNG

I cannot use the standard Page object of selenium as I cannot get it to work with Winapp Driver it crashes out with Null pointer exception. Does anyone have an example of how this can be achieved.

1
  • 1
    Theoretically how successful your page object implementation is should not depend on webdriver implementation. Can you show your problematic code?
    – Alexey R.
    Commented Jun 29, 2020 at 18:25

1 Answer 1

1

A Page Object is simply a design pattern for creating an API for UI manipulation.

enter image description here

All you have to do it to provide to the page object a way to fetch a low-level UI manipulation tool, such as Selenium. For instance, through a singleton.

class MyTests {

   @Test
   fun test1 {
      val page = FactoryOfPageObjects.newPage("login");
      val homePage = page.login("user", "1234");
      assertTrue(homePage.amILogged());
   }
}

class LogiPage {

   val driver = // You can inject any implementation of Driver here

   fun login(username, password) {
      driver.find("#usernameField").insert(username);
      driver.find("#passwordField").insert(password);
      driver.find("#loginButton").click;
      return new LoggedPage(driver);
   }
}

interface Driver {
   void insert(text);
   void click();
}

class SeleniumDriver implements Driver {...}
class AppiumDriver implements Driver {...}

See how above both your tests and your page objects have no idea about the low-level implementation of which driver you are using at run-time. Meaning that if you already have a working implementation without page objects, you can simply refactor it to isolate all references to your driver to the Driver derivatives.

See Martin Folwer's post on it for more details.

(Note for a future edit: If you provide the working implementation without the page object, the community can help you to refactor this in order to isolate the low-level details from your tests and page objects).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.