Hello, I would like to add BrowserMob Proxy Server to our project, that I can sniff network, take some HAR files etc. And got a basic problem with accessing to the *Proxy* object or even *Har* object created in *GebConfig.groovy* in just some external listener class.
So my approach was based on getters for *rawConfig* way like here: https://stackoverflow.com/questions/15395379/geb-configuration. So I tried do it this way: *GebConfig.groovy* //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())) } } //... Now in project testNGlistener want to access to shutdown the *proxy* and attach the *har* file on to report on failure: @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") } } Basically, the question is: Is it a right approach? Currently I see that * browser.config.rawConfig.**get* is working, but browserMobProxy object in *GebConfig.groovy *is not working as it should. It's not found inside browserMobProxyCapabilities method. -- 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 [email protected]. To post to this group, send email to [email protected]. 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.
