waiting: on module content, complex at clauses

108 views
Skip to first unread message

Samuel Rossinovic

unread,
Oct 12, 2017, 5:10:14 AM10/12/17
to Geb User Mailing List
Hi.
  • What is the effect of setting (wait: true) on a content template that is a Module? a ModuleList?
  • atCheckWaiting can be used to wait for a page to finish loading. Is there an equivalent method to wait for a module to finish loading?
  • Can an at clause contain a complex condition for verification (a set of conditions? a function?) If so, would atCheckWaiting work with such a clause? or should such a clause use waitFor() explicitly? 
Thank you.

Marcin Erdmann

unread,
Oct 12, 2017, 4:41:40 PM10/12/17
to Geb User Mailing List
On Thu, Oct 12, 2017 at 10:10 AM, Samuel Rossinovic <samuel.r...@gmail.com> wrote:
  • What is the effect of setting (wait: true) on a content template that is a Module? a ModuleList?
Setting wait to true on a content template will cause waiting until that temple returns a truthy (see Groovy Truth at http://groovy-lang.org/semantics.html#Groovy-Truth) value. Lists evaluate to true if they are not empty and modules evaluate to true (https://github.com/geb/geb/blob/aafa92deabceca64fa94da28d4ea175eaad4618f/module/geb-core/src/main/groovy/geb/Module.groovy#L120) when their base navigator is not empty because non empty navigators evaluate to true (https://github.com/geb/geb/blob/aafa92deabceca64fa94da28d4ea175eaad4618f/module/geb-core/src/main/groovy/geb/navigator/AbstractNavigator.groovy#L58). 
  • atCheckWaiting can be used to wait for a page to finish loading. Is there an equivalent method to wait for a module to finish loading?
I do not think there is. How would you define loading for modules? 
  • Can an at clause contain a complex condition for verification (a set of conditions? a function?) If so, would atCheckWaiting work with such a clause? or should such a clause use waitFor() explicitly?
An at check can contain however complex verification you wish including method calls and what not. At check complexity has no bearing on at check waiting. It should work even with complex verification conditions.

Marcin

Samuel Rossinovic

unread,
Feb 22, 2018, 5:31:24 PM2/22/18
to Geb User Mailing List
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

Marcin Erdmann

unread,
Mar 6, 2018, 3:08:38 PM3/6/18
to Geb User Mailing List
On Thu, Feb 22, 2018 at 10:31 PM, Samuel Rossinovic <samuel.r...@gmail.com> wrote:

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.

Module's base navigator should never be null. I it was null then you would be getting an NPE and not a missing RequiredPageContentNotPresent exception. 
Reply all
Reply to author
Forward
0 new messages