0

I have a number of geb functional tests for a grails application.

The tests are working as expected when executed from terminal or IDE. Although the tests need to be executed by hudson, so they are run in headless mode using Xvfb.

The problem is that the tests keep failing, or behaving unexpectedly, returning errors like RequiredPageContentNotPresent and Stale Element Reference Exception in places that doesn't make sense.

For example: (at LicencePage is verified above, and page isn't changed)

when:
   addDocument(Data.Test_Doc_name,Data.Test_Doc_file)

sometimes throws

 Failure:  Add Actual Licence (HomePageSpec)
|  geb.error.RequiredPageContentNotPresent: The required page content 'addDocument - SimplePageContent (owner: LicencePage, args: [Functional Test Doc, /var/lib/hudson/jobs/KB-Functional_Tests/workspace/app/../manual_test_data/so_v3/os_test_1], value: null)' is not present
    at geb.content.TemplateDerivedPageContent.require(TemplateDerivedPageContent.groovy:61)
    at geb.content.PageContentTemplate.create_closure1(PageContentTemplate.groovy:63)
    at geb.content.PageContentTemplate.create(PageContentTemplate.groovy:82)
    at geb.content.PageContentTemplate.get(PageContentTemplate.groovy:54)
    at geb.content.NavigableSupport.getContent(NavigableSupport.groovy:45)
    at geb.content.NavigableSupport.methodMissing(NavigableSupport.groovy:121)
    at geb.Browser.methodMissing(Browser.groovy:194)
    at geb.spock.GebSpec.methodMissing(GebSpec.groovy:51)
    at HomePageSpec.Add Actual Licence (HomePageSpec.groovy:228)

The method addDocument() is defined on an 'abstract' page, which LicencePage is extending. In most cases like this, if I copy the method code directly into my Spec, it is going to work, although its ruining all the structure I have on my test pages.

Anyone has experience running geb tests with Xvfb? Have you faced these issues?

All tests are passing when executed locally, and this not a data issue as the DB is always cleared

Also, without making any changes, the tests are behaving non-deterministic (on hudson) so the above exception is not always thrown. Without any changes at all, tests are sometimes successful and sometimes fail.

Giannis
  • 5,286
  • 15
  • 58
  • 113

1 Answers1

2

The description you gave seems to be the symptom of a flackey test-suite. we were facing this problem as well some time ago. A good starting point for this is this presentation (around min. 35) and the documentation about the wait stuff in geb.

If you think, it could have something to do with xvfb (where i have no experiences with), you could try to use phantomjs as the test-runner and check if it works correctly.

Mario David
  • 1,595
  • 11
  • 19