Native Automation with Geb/Cucumber?

Hey everyone.

Does anyone have any experience with using Geb and Cucumber in testing Native Apps?

Trying to figure out why I cant use the Geb Page object in my tests. Seems to time out on me and throw the following …

Caused by: geb.error.UndefinedAtCheckerException: No at checker has been defined for page class geb.Page.
	at geb.Page.verifyThisPageAtOnly(Page.groovy:231)
	at geb.Page.verifyAt(Page.groovy:182)
	at geb.Browser.methodMissing(Browser.groovy:207)
	at com.pages.Workflows$_navigate_closure1$_closure3.doCall(Workflows.groovy:29)
	at com.pages.Workflows$_navigate_closure1$_closure3.doCall(Workflows.groovy)
	at geb.waiting.Wait.waitFor(Wait.groovy:127)
	at geb.waiting.Wait$waitFor.call(Unknown Source)
	at geb.waiting.DefaultWaitingSupport.doWaitFor(DefaultWaitingSupport.groovy:51)
	at geb.waiting.DefaultWaitingSupport.this$2$doWaitFor(DefaultWaitingSupport.groovy)
	at geb.waiting.DefaultWaitingSupport.waitFor(DefaultWaitingSupport.groovy:38)
	at geb.waiting.WaitingSupport$waitFor.call(Unknown Source)
	at geb.Page.waitFor(Page.groovy:506)
	at geb.Page.waitFor(Page.groovy)
	at geb.Browser.methodMissing(Browser.groovy:207)
	at geb.Browser.invokeMethod(Browser.groovy)
	at com.pages.Workflows$_navigate_closure1.doCall(Workflows.groovy:29)
	at com.pages.Workflows$_navigate_closure1.doCall(Workflows.groovy)
	at geb.Browser.drive(Browser.groovy:1047)
	at geb.Browser$drive$1.callStatic(Unknown Source)
	at geb.Browser.drive(Browser.groovy:1017)
	at geb.Browser$drive$0.call(Unknown Source)
	at com.pages.Workflows.navigate(Workflows.groovy:27)
	at com.pages.Workflows$navigate.call(Unknown Source)
	at com.stepDefs.LoginPageSteps$_run_closure3.doCall(LoginPageSteps.groovy:51)
	at cucumber.runtime.groovy.GroovyBackend.invoke(GroovyBackend.java:155)
	at cucumber.runtime.groovy.GroovyStepDefinition$1.call(GroovyStepDefinition.java:71)
	at cucumber.runtime.Timeout.timeout(Timeout.java:13)
	at cucumber.runtime.groovy.GroovyStepDefinition.execute(GroovyStepDefinition.java:68)
	at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:37)
	at cucumber.runtime.Runtime.runStep(Runtime.java:299)
	at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
	at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
	at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:44)
	at cucumber.runtime.model.CucumberFeature.run(CucumberFeature.java:165)
	at cucumber.runtime.Runtime.run(Runtime.java:121)
	at cucumber.api.cli.Main.run(Main.java:36)
	at cucumber.api.cli.Main.main(Main.java:18)

Thus may be a result of how I am implementing this?

Can you paste the contents of at block in your GEB code ?

Here you go, its kept very simple for my purposes of making this work.

package com.pages

import geb.Browser
import geb.Page
import org.openqa.selenium.By

class Workflows extends Page {

    static at = {
        signIn.text() == "Sign In"
    }
    static content = {
        signIn { $(By.name('signInButton')) }
        email { $(By.name('emailTextField')).firstElement() }
        accessCode { $(By.name('accessCodeTextField')).firstElement() }
        resendAccessButton { $(By.name('resendAccessButton')) }
        ccLogo { $(By.name('ccLogoImage')) }
    }

    /**
     * Navigate user login screen
     *
     */
    static void navigate(){

        Browser.drive {
            //to LRLoginScreen
            waitFor { browser.verifyAt() }
        }
    }
}

I think it should be .equals() instead of ==

signIn.text() == "Sign In"

No dice. Exact same error.
Seems almost like it doesn’t know what to do with Gebs Page class for some reason. I don’t think its even getting into the check itself and falling down before that.

I know, you might have done this before, just to rule this option out, i want you to clean and rebuild the project.

Yeah, I have done it before but just did it again as a sanity check for me and no luck :frowning:
This one is a real head scratcher, not sure why it is not licking the ‘at’ check.

Caused by: geb.error.UndefinedAtCheckerException: No at checker has been defined for page class geb.Page.

Just makes no sense lol

Try something like this and see (just for debugging). use waitFor() {}

   ` waitFor (message: 'Some message to display upon failure') {signIn.text().equals("Sign In")}`

Boooo! Same outcome.

go “http://link to login screen”

have you done this ?

No, because this is a native application, not a web app.
So there is no http reference link.

Put page Workflows before browser.verifyAt()

I assume mean something like this? …

static void navigate(){

        Browser.drive {
            //to LRLoginScreen
            waitFor { Workflows browser.verifyAt() }
        }
    }

If so, still the same error, it keeps getting hung up on the ‘at’ checker for some reason.

I meant something like this

static void navigate(){

        Browser.drive {
            //to LRLoginScreen
           page Workflows 
            waitFor { browser.verifyAt() }
        }
    }

Holy @#%&^% that worked!

Can you explain to me how or why it did? I am not completely clear.

You need to let GEB know the page in which it should verify the at condition. you can also use something like this.

at Workflows

instead of

page Workflows 
waitFor { browser.verifyAt() }

Ah, yes. That makes sense then.
I tried your other suggestion and just went with

at Workflows

It is much cleaner and works just as well.
Appreciate the help here, you have been a life saver. I was stuck on this for a few days.

1 Like

Perfect ! :relieved: