geb/geb — pull request #84 by zhanghuabin (2014-12-07 17:09:58+00:00)
Title: To fix an issue of throwing NPE when calling Browser.to(Class) method.

Given we have some page classes:

abstract class BasePage extends Page {
def context = [:]

@Override
void onUnload(Page newPage) {
newPage.context << context
}
}

class FirstPage extends BasePage {}

class SecondPage extends BasePage {
static at = {
context.prop1 == label1.text()
context.prop2 == label2.text()
}
static content = {
prop1 {...}
prop2 {...}
}
}

And this is test case as below:

When:
to FirstPage

And:
context << [prop1: "abc", prop2: "123"]
// do something

And:
to SecondPage

The last step will cause throwing NPE in the "At Verifier" of SecondPage.

The root cause is that the Browser.to(Class) will create two differnt instances of Page class.