Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detecting errors in the browser with Selenium #5777

Closed
staplesj opened this issue Apr 13, 2018 · 1 comment
Closed

Detecting errors in the browser with Selenium #5777

staplesj opened this issue Apr 13, 2018 · 1 comment

Comments

@staplesj
Copy link

staplesj commented Apr 13, 2018

Meta -

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());
	}`

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

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

Since Firefox version 48, Mozilla requires all add-ons to be signed. Until
recently, Firefox support in Selenium was exclusively provided by an add-on.
As this add-on is not currently signed, this solution does not work with the
latest Firefox releases. As an alternative, Mozilla are working on a WebDriver
specification compliant implementation named GeckoDriver. Please note that the specification is not complete, and that Selenium itself does not comply with
the specification at this time. This means that features previously available
through Selenium will not be available using GeckoDriver.

Any issue logged here for Firefox 48 or later will be closed as a duplicate of
#2559. Our recommendation is to switch to GeckoDriver, or to continue testing
on Firefox 45 until GeckoDriver is a viable option for you. If you are
interested in helping us to sign the add-on to restore support for later
Firefox versions, please see the following comment for what's needed:
#2942 (comment)

If the issue is with Google Chrome consider logging an issue with chromedriver instead:
https://sites.google.com/a/chromium.org/chromedriver/help

If the issue is with Microsoft Edge consider logging an issue with Microsoft instead:
https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/

If the issue is with Firefox GeckoDriver (aka Marionette) consider logging an issue with Mozilla:
https://bugzilla.mozilla.org/buglist.cgi?product=Testing&component=Marionette

If the issue is with Safari, only Safari 10+ is supported. Please log any Safari issue with Apple:
https://bugreport.apple.com/

If the issue is with PhantomJS consider logging an issue with Ghostdriver:
https://github.com/detro/ghostdriver

-->

Browser Version:

Expected Behavior -

Actual Behavior -

Steps to reproduce -

@barancev
Copy link
Member

Watch this issue: mozilla/geckodriver#284

@lock lock bot locked and limited conversation to collaborators Aug 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants