getting browser logs

39 views
Skip to first unread message

medv...@gmail.com

unread,
Jul 9, 2021, 9:06:10 AM7/9/21
to Geb User Mailing List
hi,

do you have any suggestion how to include this https://stackoverflow.com/questions/25431380/capturing-browser-logs-with-selenium-webdriver-using-java/26488661 into the framework to get chrome browser console logs?

as this 

LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.BROWSER, Level.ALL);
caps.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);


gives me an error:

Caused by: groovy.lang.MissingMethodException: No signature of method: org.openqa.selenium.logging.LoggingPreferences.enable() is applicable for argument types: (ConfigObject, ConfigObject) values: [[:], [:]]
Possible solutions: enable(java.lang.String, java.util.logging.Level), any()


Marcin Erdmann

unread,
Jul 12, 2021, 4:05:54 PM7/12/21
to geb-...@googlegroups.com
The error you got suggests to me that you forgot to import LogType.BROWSER and Level.ALL.

Marcin

--
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+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/3cb94fa7-e8f6-4246-91ec-64c94561ce69n%40googlegroups.com.

Alexander Kriegisch

unread,
Jul 14, 2021, 2:41:09 AM7/14/21
to geb-...@googlegroups.com

I tried this in my old Spock 1.3, Selenium 3.14.0, Geb 3.0.1 example project. It seems to work, if I have the right imports in my GebConfig.groovy file and this section for the Chrome browser:

environments {
chrome {
driver = {
WebDriverManager.chromedriver().arch32().setup()

LoggingPreferences logPrefs = new LoggingPreferences()
logPrefs.enable(LogType.BROWSER, Level.ALL)
      def options = new ChromeOptions()
options.setCapability(CapabilityType.LOGGING_PREFS, logPrefs)
// Avoid "Chrome is being controlled by automated test software" pop-up
options.addArguments("disable-infobars")
new ChromeDriver(options)
}
}
// other drivers
}
I use an options object and set capabilities on that one, because I am also using options directly. There is no Chrome driver constructor taking both options and capabilities. I guess, you can adjust that to your needs.
--
Alexander Kriegisch
https://scrum-master.de
Reply all
Reply to author
Forward
0 new messages