WebDriver 在 Geb + Spock 规范后不自动清除

WebDriver not auto clearing after Geb + Spock specs

当 运行 多次测试时,驱动程序不会自动清除以使用新规格的干净平板。我如何实现此功能以在每个规范后清理驱动程序?

我注意到很多关于这个问题的问题,但似乎没有人指出一个非常简单的内置解决方案。

只需将 autoClearWebStorage = true 放入 GebConfig.groovy 文件即可。就是这样!

Link to documentation explaining how this is off by default here

Certain integrations will automatically clear the driver’s web storage, that is both local and session storage, which is usually necessary when using an implicit driver. This configuration flag, which is false by default, can be enabled by setting the autoClearWebStorage value in the config to true.

autoClearWebStorage = true