0

I am a new user of Play and working through the ToDo List example (the beginner Java-based tutorial).

I am now experimenting with adding test cases using the Page Object Pattern (https://github.com/FluentLenium/FluentLenium#page-object-pattern).

Unfortunately, my initial attempts to implement this pattern have not gone well. My entire system is available at GitHub if you would like to quickly download and play with it. Here is a link to my test class, which shows both a running test case (that does not use the Page Object Pattern) and a failing test case that attempts to use the Page Object Pattern:

https://github.com/philipmjohnson/playexample1/blob/master/test/IntegrationTest.java

Here is the error when I run the test cases inside the Play console):

[error] Test IntegrationTest.testWithPage failed: java.lang.NullPointerException
[error]     at play.test.Helpers.running(Helpers.java:426)
[error]     at IntegrationTest.testWithPage(IntegrationTest.java:34)
[error]     ...
[error] Caused by: java.lang.NullPointerException
[error]     at org.fluentlenium.core.Fluent.goTo(Fluent.java:223)
[error]     at org.fluentlenium.core.FluentPage.go(FluentPage.java:55)
[error]     at org.fluentlenium.core.Fluent.goTo(Fluent.java:204)
[error]     at IntegrationTest$2.invoke(IntegrationTest.java:37)
[error]     at IntegrationTest$2.invoke(IntegrationTest.java:34)
[error]     at play.test.Helpers.running(Helpers.java:424)

How do I correctly implement the Page Object design pattern?

Philip Johnson
  • 1,463
  • 2
  • 11
  • 20

1 Answers1

2

Some details there :

You have to construct the page and giving it the webdriver, the page need it to manipulate the browser.

public ToDoListPage(WebDriver webDriver) {
    super(webDriver);
}

And in your test :

ToDoListPage todopage = new ToDoListPage(browser.getDriver());

Also, doesn't need to have a @Test annotation in your TodoListPage

See the pull request : Fix

Mathilde
  • 98
  • 4