Note that there are some explanatory texts on larger screens.

plurals
  1. POGeb 'at null' when asserting page
    primarykey
    data
    text
    <p>I'm trying to write a simple Geb/Spock test using Grails but I am receiving the following test failure. </p> <pre><code>| Failure: login works correctly(...UserAuthAcceptanceSpec) | Condition not satisfied: at HomePage | null </code></pre> <p>I can follow the test through with a debugger using a browser and can see that the application works as expected and the correct heading is being shown. However, the test is failing when I try to invoke the <code>at</code> checker. Can anyone tell me why the final assertion in the test might be failing and why the 'at' checker appears to be null? </p> <p>Here is my code: (Geb v0.9.0, Grails 2.2.2)</p> <p><strong>Spock Specification:</strong></p> <pre><code>class UserAuthAcceptanceSpec extends GebReportingSpec { def "login works correctly"() { given: "the correct credentials" def theCorrectUsername = "admin" def theCorrectPassword = "password" when: "logging in" to LoginPage username = theCorrectUsername password = theCorrectPassword submitButton.click() //([HomePage, LoginPage]) then: "the welcome page is shown" heading =~ /(?i)Welcome.*/ // &lt;- same as 'at' checker in HomePage and: "the 'at' checker works" at HomePage // &lt;- fails } </code></pre> <p><strong>LoginPage</strong>:</p> <pre><code>class LoginPage extends Page { final String path = "/login/auth" static content = { heading(required: false, wait:true) { $("h1").text() } username { $("input", name:"j_username") } password { $("input", name:"j_password") } submitButton { $("input", id:"submit") } } static at = { title =~ /Login.*/ } } </code></pre> <p><strong>HomePage</strong>:</p> <pre><code>class HomePage extends Page { final String path = "/" static content = { heading(required: false, wait:true) { $("h1").text() } } static at = { heading =~ /(?i)Welcome.*/ } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload