Closed Bug 1453962 Opened 4 years ago Closed 4 years ago

Add support for Selenium’s logging interface

Categories

(Testing :: geckodriver, defect, P3)

56 Branch
defect

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: stephen.staple, Unassigned)

References

()

Details

(Whiteboard: [blocked by spec])

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36

Steps to reproduce:

OS:  
Windows 10 Pro for Workstations

Selenium Version:  
3.8.1
Browser:  
Firefox Quantum 59.0.2 (64-bit)

I am trying to capture errors using Java & Selenium, using this method: https://advancedweb.hu/2016/03/29/selenium-tes-logs/

Here I set up the log:

`                       

			
			global.variables.logs = new LoggingPreferences();
			
			global.variables.logs.enable(LogType.BROWSER, Level.SEVERE);
			
			DesiredCapabilities desiredCapabilities = DesiredCapabilities.firefox();
			
			desiredCapabilities.setCapability(CapabilityType.LOGGING_PREFS, global.variables.logs);
			
			System.setProperty("webdriver.gecko.driver", filename);
			
			FirefoxOptions options = new FirefoxOptions()
					.merge(desiredCapabilities)
					.addPreference("browser.tabs.remote.autostart", false)
					.addPreference("security.sandbox.content.level", 5);

			driver = new FirefoxDriver(options);`

Here I try to print out any messages in those logs:

`		

		System.out.println(thisClass + " Checking for log entries. ");

		try {
			LogEntries logEntries = driver.manage().logs().get(LogType.BROWSER);
			
			if (logEntries != null) {
				System.out.println(thisClass + " logEntries is not null. ");
				for (LogEntry logEntry : logEntries) {
					// Get log message, timestamp and level.
					Common.printLine();
					debug.print(thisClass + " logEntry.getTimestamp : " + logEntry.getTimestamp());
					debug.print(thisClass + " logEntry.getMessage : " + logEntry.getMessage());
					debug.print(thisClass + " logEntry.getClass : " + logEntry.getClass());
					debug.print(thisClass + " logEntry.getLevel : " + logEntry.getLevel());
					Common.printLine();
				}
			}else {
				System.out.println(thisClass + " logEntries is null. ");
			}

		} catch (Exception e) {
			int errorCode=1523626889;
			System.out.println(thisClass + " Could not generate device logs. ");
			System.err.println(thisClass + " errorCode: " + errorCode + " Exception: " + e.getMessage());
		}`


If this method is no longer available, how else might we capture errors from the browser?


Actual results:

When running it, I get an error:

> Exception: POST /session/5ff98e14-c578-461c-aae2-8dc7cb3ffbec/log did not match a known command
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'
System info: host: 'SSTAPLE', ip: '172.16.190.147', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_151'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 59.0.2, javascriptEnabled: true, moz:accessibilityChecks: false, moz:headless: false, moz:processID: 13892, moz:profile: C:\Users\SStaple\AppData\Lo..., moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, pageLoadStrategy: normal, platform: XP, platformName: XP, platformVersion: 10.0, rotatable: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}}
Session ID: 5ff98e14-c578-461c-aae2-8dc7cb3ffbec


Expected results:

Displays errors encountered (which I can otherwise see by clicking F12 in Firefox & viewing the Console log.)
Please see https://github.com/mozilla/geckodriver/issues/284.

This is not supported yet.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: Detecting errors in the browser with Selenium → Add support for Selenium’s logging interface
Priority: -- → P3
Whiteboard: [blocked by spec]
Yes, I understand it is not supported yet. What I am asking is how else might we capture errors from the browser? See my question - above!
We will not be adding support for the Selenium log API.
https://github.com/w3c/webdriver/issues/406 tracks defining a log
API in WebDriver, and I believe Simon Stewart had a proposal for
it at the F2F in Burlingame, but I can’t find it written down.  The
meeting minutes should be accessible though.
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → WONTFIX
(In reply to Stephen from comment #2)
> Yes, I understand it is not supported yet. What I am asking is how else
> might we capture errors from the browser? See my question - above!

What kind of failures do you want to see exactly? Do you have an example? Basically all logging we currently have should go into the geckodriver.log. Best is to use it with the trace level: https://firefox-source-docs.mozilla.org/testing/geckodriver/geckodriver/TraceLogs.html.
You need to log in before you can comment on or make changes to this bug.