Hi,

i tried with the same way as :

  waitFor(60) {
    ObjName.click()
    true
  }

  but it didn't worked


  My exact issue is that waitFor works find in "Login" class which follows
exact geb POM where i have created static at , static url , static content
  and follows with method implementation and same class i have extends from
Page(geb.Page),

  package pages

import geb.Browser
import geb.Page
import modules.OperationUtil



class Login extends Page {


    static at = {title == "Login"}

    static content = {
        usernameField {$('input#username')}
        passwordField {$('input#password')}
        logInButton {$('button#login-submit')}

    }

    def "login To App"(username, password) {
        try {
            OperationUtil operationUtil = new OperationUtil();

            waitFor(60) {
                operationUtil.enterVal(usernameField, username);
                operationUtil.enterVal(passwordField, password);
            }

            operationUtil.clickAnElement(logInButton)

            waitFor(Integer.parseInt(ju.getJsonValue("maxWait"))) {
logoutButton.displayed
                slide.displayed }
        }
        catch(Exception e){
            new ExceptionHandler().customizedException("Cannot login into
the application");
            e.printStackTrace();
        }
    }
}

  but in other class "OperationUtil" where i have only extends with Page
(geb.Page) and does method implementation.

  package modules

  import geb.Page

  class OperationUtil extends Page {


    def clickAnElement(objName){
            waitFor(60) {
                objName.click()
return true
            }

        }



}



so waitFor at OperationUtil doesn't work.



2020-06-12 11:53:42 ERROR - Issue with login: Instance of page class
modules.OperationUtil has not been initialized.
Please pass it to Browser.to(), Browser.via(), Browser.page() or
Browser.at() before using it.
2020-06-12 11:53:42 ERROR - Issue with login: Instance of page class
modules.OperationUtil has not been initialized.
Please pass it to Browser.to(), Browser.via(), Browser.page() or
Browser.at() before using it.
geb.error.PageInstanceNotInitializedException: Instance of page class
modules.OperationUtil has not been initialized.
Please pass it to Browser.to(), Browser.via(), Browser.page() or
Browser.at() before using it



Regards,
Avinash Kumar

On Fri, Jun 12, 2020 at 10:39 AM Michael Kutz <[email protected]> wrote:

> The waitFor expects a closure returning a boolean value. Once the value
> returned is true, the waiting ends.
>
> As Groovy interprets basically any object as an boolean (see
> http://groovy-lang.org/semantics.html#Groovy-Truth), this works great
> with Geb's NonEmptyNavigator (true) and EmptyNavigator (false).
>
> In your case, you call click. As click returns null, the result will never
> be true.
>
>   waitFor(60) { ObjName }.click()
>
> Might work, but you should put the object retrieving inside the closure.
>
>   waitFor(60) {
>     ObjName.click()
>     true
>   }
>
> Might also work if the first line on the closure will throw an exception,
> which would be catched by Wait. If no exception is thrown, the true will be
> returned and the waiting will end.
>
> Kind regards,
> Micha
>
> Avinash Kumar <[email protected]> schrieb am Do., 11. Juni 2020,
> 16:50:
>
>> Hi,
>>
>> I am trying to use waitFor method in different class other than page
>> class.
>>
>> For example:
>>
>> class test extends page {
>>
>>
>> def clickAnElement(ObjName)
>> {
>>
>> waitFor(60)
>>  {
>>  ObjName.click()
>> }
>> }
>> }
>>
>>
>> and clickAnElement, i am calling from one page class .
>> but code fails at WaitFor() as WaitFor is not working for me in class
>> other than page class.
>>
>>
>> Can any help me out in this case. Please
>>
>> Thanks
>> Regards,
>> Avinash Kumar
>>
>> --
>> 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 [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/geb-user/CAMMvVTQGSi1pUnfqADqRGAmTWZjKNZZV11oEY7zOdS1dcFsmMA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/geb-user/CAMMvVTQGSi1pUnfqADqRGAmTWZjKNZZV11oEY7zOdS1dcFsmMA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/geb-user/CALYktxNGr4FTR_9TfukTRcRmYa%2BpDJX8B0sruFC-KfGZCA0OKA%40mail.gmail.com
> <https://groups.google.com/d/msgid/geb-user/CALYktxNGr4FTR_9TfukTRcRmYa%2BpDJX8B0sruFC-KfGZCA0OKA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/geb-user/CAMMvVTSFuZCQozoR_A65rvoamYGo43XFAr_7V_SaXp%2BVvsSBPQ%40mail.gmail.com.

Reply via email to