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

Chromium with GebReportingSpec fails with groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method geb.report.Base64#decode. #292

Closed
geb-bot opened this Issue Mar 11, 2014 · 5 comments

Comments

Projects
None yet
2 participants
@geb-bot

geb-bot commented Mar 11, 2014

Originally created by Lee Davis.

Ubuntu 13.10 - 3.11.0-18-generic
Java Version - 1.7.0_51
Grails 2.3.7

Testing a custom build of chromium, with chromedriver 2.9/selenium-chrome-driver:2.40.0

Running spec extending GebSpec everything works as expected, but as soon as I extend GebReportingSpec and run the same spec, I receive the following error:
{noformat}
groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method geb.report.Base64#decode.
Cannot resolve which method to invoke for [null] due to overlapping prototypes between:
[class [B]
[class [C]
[class java.lang.String]
at geb.report.ScreenshotReporter.writeReport(ScreenshotReporter.groovy:37)
at geb.report.CompositeReporter.writeReport(CompositeReporter.groovy:31)
at geb.Browser.report(Browser.groovy:775)
at geb.spock.GebReportingSpec.report(GebReportingSpec.groovy:44)
at geb.spock.GebReportingSpec.cleanup(GebReportingSpec.groovy:39)
{noformat}

@geb-bot

This comment has been minimized.

geb-bot commented Mar 12, 2014

Originally posted by Lee Davis.

Curious if there is anything related to this issue noted on stacktrace with NULL and method overloading?

http://stackoverflow.com/questions/12528823/unexpected-behavior-with-overloaded-methods

It's a (somewhat little-known) oddity of Groovy's multi-dispatch mechanism, which as attempting to invoke the "most appropriate" method, in combination with the fact that the provided static type (in your case A or B) is not used as part of the dispatch mechanism. When you declare A a = null, what you get is not a null reference of type A, but a reference to NullObject.

Ultimately, to safely handle possibly null parameters to overloaded methods, the caller must cast the argument, as in

A a = null
assert foo.foo('foo', a as A) == 'a'

@geb-bot

This comment has been minimized.

geb-bot commented Mar 13, 2014

Originally posted by Lee Davis.

https://github.com/geb/geb/blob/master/module/geb-core/src/main/groovy/geb/report/ScreenshotReporter.groovy#L37
Changing the following line:
From:
decoded = Base64.decode(rawBase64)
To:
decoded = Base64.decode(rawBase64 as String)
...fixes the problem, but I run into another issue where screenshots fail and I get the error, "Unable to receive message from renderer"
{noformat}
org.openqa.selenium.WebDriverException: chrome not reachable
(Session info: chrome=content shell)
(Driver info: chromedriver=2.9.248304,platform=Linux 3.11.0-18-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 2 milliseconds
Build info: version: '2.40.0', revision: '4c5c0568b004f67810ee41c459549aa4b09c651e', time: '2014-02-19 11:13:01'
System info: host: 'UBUNTU-13-GNOME-01', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.11.0-18-generic', java.version: '1.7.0_51'
Session ID: ea5b688f6e5aa7d1cb9759f259871eb5
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=ANY, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome, chrome={}, rotatable=false, locationContextEnabled=true, version=content shell, takesHeapSnapshot=true, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, nativeEvents=true, webStorageEnabled=true, applicationCacheEnabled=false, takesScreenshot=true}]
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:573)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:588)
at org.openqa.selenium.remote.RemoteWebDriver.getCurrentUrl(RemoteWebDriver.java:293)
at com.drc.test.LoginPage._clinit__closure1(LoginPage.groovy:9)
at com.drc.test.LoginPage._clinit__closure1(LoginPage.groovy)
at geb.Page.verifyThisPageAtOnly(Page.groovy:165)
at geb.Page.verifyAt(Page.groovy:133)
at geb.Browser.doAt(Browser.groovy:358)
at geb.Browser.at(Browser.groovy:289)
at geb.spock.GebSpec.methodMissing(GebSpec.groovy:51)
at com.drc.test.FooBarSpec.Can Login with Math99_closure2(FooBarSpec.groovy:37)
at com.drc.test.FooBarSpec.Can Login with Math99_closure2(FooBarSpec.groovy)
at geb.waiting.Wait.waitFor(Wait.groovy:117)
... 6 more
{noformat}

@geb-bot

This comment has been minimized.

geb-bot commented Mar 17, 2014

Originally posted by Luke Daley.

Thanks for the thorough report. We'll get this fixed.

@geb-bot

This comment has been minimized.

geb-bot commented Mar 17, 2014

Originally posted by Lee Davis.

Thanks Luke! Besides the problem listed above with the Base64 decoding, there appears to be a limitation with CEF3.1650 and earlier that breaks browser reporting used by GebReportingSpec . This has been addressed is CEF3.1750 and later. Also with CEF3.1750 and later it never hits the "NULL" scenario of determineScreenshotDriver, which appears to only happen if there is a bigger problem. Regardless, it would be great to not to barf at this point. Cheers Lee.

@geb-bot

This comment has been minimized.

geb-bot commented Jan 17, 2015

Resolved

@geb-bot geb-bot added the Bug label Apr 12, 2015

@geb-bot geb-bot added this to the 0.10.1 milestone Apr 12, 2015

@geb-bot geb-bot closed this Apr 12, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment