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

On Friday, October 13, 2017 at 7:41:40 AM UTC+11, Marcin Erdmann wrote:
>
> On Thu, Oct 12, 2017 at 10:10 AM, Samuel Rossinovic <samuel.r...@gmail.com 
> <javascript:>> 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
>

-- 
You received this message because you are subscribed to the Google Groups "Geb 
User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to geb-user+unsubscr...@googlegroups.com.
To post to this group, send email to geb-user@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/geb-user/f4809893-edb7-4f72-956a-3ecb135232c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to