rhinds
rhinds

Reputation: 10043

Turn off FireFox driver refresh POST warning

I have inherited some GEB tests that are testing logging into a site (and various error cases/validation warnings).

The test runs through some validation failures and then it attempts to re-navigate to the same page (just to refresh the page/dom) and attempts a valid login. Using GEB's to() method, it detects that you are attempting to navigate to the page you are on, it just calls refresh - the problem here is that attempts to refresh the last POST request, and the driver displays the

"To display this page, Firefox must send information that will repeat any action (such as a search or order confirmation) that was performed earlier"

message - as the test is not expecting this popup, it hangs and the tests timeout.

Is there a way to turn off these warnings in Firefox webdriver? or to auto-ignore/accept them via Selenium or GEB?

GEB Version: 0.9.2, Selenium Version: 2.39.0

(Also tried with minor version above: 0.9.3 & 2.40.0)

Caveats:

Upvotes: 1

Views: 1594

Answers (2)

erdi
erdi

Reputation: 6954

That refresh() is there to work around an issue with IE driver which ignores calls to driver.get() with the same url as the current one.

Instead of monkey patching Browser class (which might bite you somewhere down the line or might not) I would change the url of your login page class. You might for example add an insignificant query string - I think that simply a ? at the end should suffice. The driver.currentUrl == newUrl condition will evaluate to false and you will not see that popup anymore.

Upvotes: 3

twinj
twinj

Reputation: 2049

If I understand you issue properly this might help. In Groovy you can modify a class on the fly.

We use Spock with Geb and I placed this in a Super class which all Spock Spec inherit from. Eg: QSpec extends GebSpec.

It is the original method slightly modified with the original code commented out so you know what has been changed. I use this technique in several required places to alter Geb behaviour.

static {

    Browser.metaClass.go = { Map params, String url ->
        def newUrl = calculateUri(url, params)
        //          if (driver.currentUrl == newUrl) {
        //              driver.navigate().refresh()
        //          } else {
        //              driver.get(newUrl)
        //          }
        driver.get(newUrl)
        if (!page) {
            page(Page)
        }
    }
}

Upvotes: 2

Related Questions