I was trying to implement waiting for modules:
Multiple pages in the suite have a panel that is loaded async.
class APage extends Page {
static content {
myPanel { module new Panel('a-page-panel-1') }
}
def doInPanel() {
myPanel.button.click()
//...
}
}
class Panel extends Module {
String panelId
static base = { $(id: panelId).parent() }
static content = {
foo {//..}
bar {//..}
button {//..}
label {//..}
}
@Override
protected void initialized() {
super.initialized()
waitToFinishLoad()
}
def waitToFinishLoad() {
waitFor('somepreset') {
// loading is done when the "loading" modal is removed, and the label appears
!find { $(class: 'loading-modal', style: 'display:block') }
label
}
}
}
This fails, but only occasionally, with geb complaining:
geb.waiting.WaitTimeoutException: condition did not pass in XYZ seconds
Caused by: geb.error.RequiredPageContentNotPresent: The required page content 'Panel -> label: geb.navigator.EmptyNavigator' is not present
Debugging suggests that at the point where waitToFinishLoad() is called: 1. The page's DOM is visible to geb. 2. the module's navigator is null.
Can Module.initialized() be relied for providing an initialized navigator?
Thanks,
Sam