Problem with firefox driven when running many tests

99 views
Skip to first unread message

jérémie GUIDOUX

unread,
May 19, 2017, 5:32:49 AM5/19/17
to Geb User Mailing List
I have a strange problem with the Firefox driver.

When I launch a simple test. It works.
But when I duplicate this test it works not.
But with chrome  it works. The problem is only with firefox driver.

My test is simple: I go to the login page. write user and password and click on the login button to go to the homepage.

This is my test with the duplication : 


  def "login with valid user in the login page"() {


       
when: "I try to to go the login page"
        go
"/"
       
then: "I should be to the login page"
       
def loginPage = at LoginPage


       
when: "I log in with valid identifiers user:password"
        loginPage
.login("user", "password")
       
then: "I should be on the home page"
        at
HomePage


        cleanup
:
        logout
()




   
}


   
def "login with valid user in the login page2 "() {


       
when: "I try to to go the login page"
        go
"/"
       
then: "I should be to the login page"
       
def loginPage = at LoginPage


       
when: "I log in with valid identifiers user:password"
        loginPage
.login("user", "password")
       
then: "I should be on the home page"
        at
HomePage


        cleanup
:
        logout
()




   
}


I use the gecko driver version : v0.16.1
selenium version : 3.4.0
Geb version 1.1.1

I use the systemProperty 'webdriver.gecko.driver' to define the gecko driver location 
and I instantiate the driver like this 
```
  driver = {new FirefoxDriver()}


The error message is : 

Condition failed with Exception:


at
HomePage
|
Assertion failed:
 
title
== "Home page"
|     |
|     false
Login Page


 at org
.openclassrooms.cities.web.geb.LoginAccessPage2.login with valid user in the login page2 (LoginAccessPage2.groovy:46)
Caused by: Assertion failed:


title
== "Home page"
|     |
|     false
Login Page


 at org
.openclassrooms.cities.web.geb.page.HomePage._clinit__closure1(HomePage.groovy:11)
 at org
.openclassrooms.cities.web.geb.page.HomePage._clinit__closure1(HomePage.groovy)
 at geb
.Page.verifyThisPageAtOnly(Page.groovy:245)
 at geb
.Page.getAtVerificationResult(Page.groovy:223)
 at geb
.Page.verifyAt(Page.groovy:194)
 at geb
.Browser.doAt(Browser.groovy:457)
 at geb
.Browser.at(Browser.groovy:339)
 at geb
.spock.GebSpec.methodMissing(GebSpec.groovy:56)




The problem is that the click() method on the login button not work the second time I think. But it works the first time. I guess it is more that the second time we are not in a clean context, but I don't know why :
This is a part of  the code of my LoginPage : 

static content = {
        loginForm
{ $("#login-form") }
        usernameInputField
{ loginForm.username() }
        passwordInputField
{ loginForm.password() }
        submitButton
() {
            loginForm
.find("input", type: "submit")
       
}

}

void login(String username, String password) {
        usernameInputField
<< username
        passwordInputField
<< password
        submitButton
.click()


   
}



Do you have some idea of what can happens ? 

Thank you

Marcin Erdmann

unread,
May 19, 2017, 9:36:54 AM5/19/17
to Geb User Mailing List
Is the login action synchronous (i.e. using a regular form post) or asynchronous (e.g. using AJAX or part of a single page application)? If you take screenshots at the end of each test (e.g. using GebReportingSpec) do you see the login page or home page when the test fails?

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to geb-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/6967bb84-bca0-479b-bdaa-4744ec0dfe8c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jérémie GUIDOUX

unread,
May 20, 2017, 6:38:53 AM5/20/17
to Geb User Mailing List
Thanks for your answer .)

The login action is synchronous. 

<form id="login-form" th:action="@{/login}" method="post" class="form form-login">


Apparently, the screenshot says that the test works well.

but the test fail. That's weird.

maybe a timeout problem.

To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.

Marcin Erdmann

unread,
May 21, 2017, 2:45:10 PM5/21/17
to Geb User Mailing List
Interesting. Looks like Firefox might not be waiting for the DOM to fully load before returning control to your code after a call to WebDriver#get(String). I've experienced that in the past and had people report it in this group as well. 

I would suggest you enable global at check waiting which was introduced exactly because of this behaviour of Firefox driver. Add the following to your GebConfig.groovy file (you can do that in the environment specific section of it which is used when running with Firefox if you want): 

atCheckWaiting = 1

You can have a look at the section of the manual about waiting in at checkers (http://www.gebish.org/manual/current/#at-check-waiting) to learn more.

Marcin

To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+unsubscribe@googlegroups.com.

To post to this group, send email to geb-...@googlegroups.com.

jérémie GUIDOUX

unread,
May 22, 2017, 12:29:45 PM5/22/17
to Geb User Mailing List
Thanks a lot :)
That works :)
I don't really understand why but that's work :)

 
 
Reply all
Reply to author
Forward
0 new messages