Skip to content

Explain resetBrowser() + clearCacheAndQuitDriver() trick in Book of Geb #473

@kriegaex

Description

@kriegaex

After I had answered a StackOverflow question about how to restart a browser within a test here in a rather complicated way and @erdi offered a much simpler solution here I am creating this tracking ticket:

OMG, this works and I had to use such a complicated workaround, searching my eyes out in the Book of Geb (BoG) and elsewhere. Would you mind adding this to chapters 3.1 or 3.2 where you talk about life cycle management? resetBrowser() is not mentioned a single time in the whole BoG, not to speak of the combination with clearCacheAndQuitDriver(). To document this in the BoG would be really helpful. resetBrowser() is also undocumented in the JavaDoc.

For reference, this is a simple use case:

package de.scrum_master.tdd

import geb.driver.CachingDriverFactory
import geb.spock.GebReportingSpec

class RestartBrowserIT extends GebReportingSpec {
  def "Search web site Scrum-Master.de"() {
    when:
    go "https://scrum-master.de"
    report "welcome page"

    then:
    $("h2").text().startsWith("Herzlich Willkommen bei Scrum-Master.de")

    when: "browser is reset"
    resetBrowser()
    CachingDriverFactory.clearCacheAndQuitDriver()

    and: "download page is opened in new browser"
    go "https://scrum-master.de/Downloads"
    report "download page"

    then: "expected text if found on page"
    $("h2").text().startsWith("Scrum on a Page")
  }
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions