4

Inside a Geb test, I'd like to navigate back in the browser's history (ie. to click the browser's back button). I haven't found a way to do it using Geb API.

What I do is:

driver.navigate().back()               // usage of WebDriver API
browser.page(<<previous Page class>>)  // this tells Geb that the page has changed

The code works, but I don't like the usage of WebDriver API here. Another idea would be to do it in JavaScript, but that's also something I'd like to avoid.

Is there a more Gebish way of navigating back in the browser's history?

Tomas Pinos
  • 2,812
  • 14
  • 22
  • 1
    `driver.navigate().back()` seems like exactly the right mechanism. Instead of doing the normal thing, interacting with a `Page` and clicking links, you're invoking an actual browser feature. As such, you're having to interact with `driver` directly. – inanutshellus Feb 01 '14 at 18:06

1 Answers1

5

I believe there isn't. I would also use WebDriver API to navigate back. Sometimes it's necessary to use WebDriver API, that's why the WebDriver instance is exposed on Geb's Browser class.

erdi
  • 6,944
  • 18
  • 28