如何在Geb测试中浏览浏览器的历史记录

Tom*_*nos 4 groovy automated-tests geb

在Geb测试中,我想在浏览器的历史记录中导航回来(即点击浏览器的后退按钮).我还没有找到使用Geb API的方法.

我所做的是:

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

代码有效,但我不喜欢这里使用WebDriver API.另一个想法是用JavaScript做,但这也是我想避免的.

是否有更多的Gebish方式在浏览器的历史中导航?

erd*_*rdi 5

我相信没有.我还会使用WebDriver API导航回来.有时需要使用WebDriver API,这就是为什么WebDriver实例在Geb的Browser类上公开的原因.