Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7711639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:25:36+00:00 2026-06-01T01:25:36+00:00

Scenario: I have a login page which uses ajax to validate a user and

  • 0

Scenario: I have a login page which uses ajax to validate a user and if invalid login, it stays on the same page.

I am wondering if this is the correct way to use the at in Geb or I can improvise on this. Concerns:

  1. I am using waitFor with hard-coded timeout etc.
  2. Should waitFor be in at block?
  3. Is there a better way of writing this?

Spec def

def "perform invald login"()
{
    given: "I am at the login page"
    to LoginPage

    when : "I entered invalid data"
    loginForm.loginClientCode = "test"
    loginForm.loginSystemCode = "test"
    loginForm.loginUserId = "test"
    loginForm.loginPassword = "test"

    loginButton().click()

    then: "Log in attempt unsuccessful"
    at(LoginPage)
}

Page object

class LoginPage extends Page
{
    static url = "login/login.jsf";

    static at =
    {
        waitFor(10,0.5)
        {  $("div.ic-h1").text() == "User Authentication" }
    }

    static content =
    {
        loginForm
        {
            $("form",id: "loginForm")
        }

        loginButton
        {
            $("button", id: "loginButton")
        }

        statusMessages
        {
            $('div.ui-messages').text()
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:25:37+00:00Added an answer on June 1, 2026 at 1:25 am

    We usually keep the at only for the purpose of verification and then do:

    waitFor{ at LoginPage }
    

    But this might not be needed given the new support for implicit assertions in 0.7. http://www.gebish.org/manual/snapshot/implicit-assertions.html#at_verification

    I think what you really want here is to test for the existence of an error message and waitFor that.

    i.e,

     loginButton().click()
    
     then: "Log in attempt unsuccessful"
     waitFor{ statusMessage == 'this login failed' }
    

    since you can’t really get your then condition to fail otherwise.

    Moreover, you could probably put the condition into a state of your page object, so something like

    def isErrorState() {
        statusMessage == 'this login failed'
    }
    

    and in your test, it becomes easier to read.

    waitFor{ isErrorState() } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have scenario like login page where when the user access any privileged page,
Scenario: I have a web application (SnapshotServer) which uses a WebBrowser control to take
I have an aspx master/content page scenario. The parent page has an IFrame which
Scenario : On a ASP.NET site, we have a login page (login.aspx). Within login.aspx.cs
I have the following Gherkin scenario: Scenario: User Login Given a user account exists
Scenario: I have an administration-application which manages the user accounts for another application. Now
I have a scenario where people login to the IM we developed using the
Scenario I have a DevExpress DataGrid which is bound to a DataSet in C#.
I have the following scenario: A user on one our customer's website clicks a
I'm facing a problem with the android broadcast receiver. I have a login page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.