//imports + basic configuration etc
//...
//Decleration of our Har and BrowserMobProxy objects
Har harFile = new Har();
BrowserMobProxy browserMobProxy = new BrowserMobProxyServer()
//Setup proxy server
DesiredCapabilities browserMobProxyCapabilities(DesiredCapabilities capabilities) {
browserMobProxy.start(0)
String port = browserMobProxy.getPort()
println("Proxy started at: " + port)
String PROXY = "localhost:" + port;
org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
proxy.setHttpProxy(PROXY)
.setFtpProxy(PROXY)
.setSslProxy(PROXY);
harFile = browserMobProxy.newHar("SomeData")
capabilities.setCapability(CapabilityType.PROXY, proxy);
capabilities
}
//Customize chrome profile
DesiredCapabilities chromeCapabilities(){
ChromeOptions opt = createChromeOptions()
DesiredCapabilities capabilities = DesiredCapabilities.chrome()
capabilities.setCapability(ChromeOptions.CAPABILITY, opt)
browserMobProxyCapabilities(capabilities)
capabilities
}
//Finally chrome env
environments {
// See: http://code.google.com/p/selenium/wiki/ChromeDriver
chrome {
driver = {
new ChromeDriver(chromeCapabilities (new DesiredCapabilities()))
}
}
//...
@Slf4j
class GebTestNGListener implements ITestListener, IConfigurationListener {
@Override
void onTestFailure(ITestResult result) {
if (result != null) {
log.error("FAILURE: " + getTestDescription(result));
grabScreenshots(result)
//quit proxy etc.
browser.config.rawConfig.get("browserMobProxy")
//attach harfile etc.
browser.config.rawConfig.get("harFile")
}
}
--
You received this message because you are subscribed to the Google Groups "Geb User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+unsubscribe@googlegroups.com.
To post to this group, send email to geb-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/284c4f39-9cf6-4151-b437-b7db14e10e24%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.