MarkusBernhardt / robotframework-selenium2library-java

Java port of the Selenium 2 (WebDriver) Python library for Robot Framework
Apache License 2.0
46 stars 48 forks source link

Logging throws error if logged content is over 100k long #7

Closed wiibaker closed 11 years ago

wiibaker commented 11 years ago

I encountered a problem when using Robot and Selenium2Library java to test some site.

If using a keyword like "Table Cell Should Contain" which fails if the condition is not met, the will be printed an error message along with the webpage content. Apparently if this combined logged messaged exceeds 100.000 characters, it will throw an exception instead. The exception will show as "IOException: Resetting to invalid mark".

This seems to come from a hard coded limit in Jython ParserFacade

http://grepcode.com/file/repo1.maven.org/maven2/org.python/jython-installer/2.7-b1/org/python/core/ParserFacade.java?av=h

Others have also met this problem in other situations too

http://python.6.x6.nabble.com/ScriptEngine-eval-python-file-bigger-then-100K-characters-td1778396.html

I also first raised an issue for Robot Framework if there would have been any insight on this, but as I had suspected, I was forwarded to here.

http://code.google.com/p/robotframework/issues/detail?id=1415

I do not see it very likely to get that limit off from the Jython (it might be there for a reason), so perhaps some kind of workaround could be figured out in the Selenium2Library-java to bypass this 100k limit. It is not too uncommon to have webpages more than 100k long.

The place where actual exception is thrown is in

https://github.com/MarkusBernhardt/robotframework-selenium2library-java/blob/master/src/main/java/com/github/markusbernhardt/selenium2library/keywords/Logging.java

and the lines with "loggingPythonInterpreter.get().exec("

Perhaps somekind of cap for the logoutput could be used?

wiibaker commented 11 years ago

I also have a small demo project to demonstrate this problem, but I could not paste it here as only images are supported. You can grab it from the Robot Framework issue. The file is named "robot-tests_updated.zip" ie. the second attachment in the issue.

http://code.google.com/p/robotframework/issues/detail?id=1415

MarkusBernhardt commented 11 years ago

Will look into that in the evening. Cheers, Markus

MarkusBernhardt commented 11 years ago

Fixed in 1.2.0.4.

Log messages larger than 1kB are now written to a temp file on the Java side and then read back on the Python side. This avoids long messages to get parsed by the Jython source code parser.

Will push out a release in the next minutes.

MarkusBernhardt commented 11 years ago

Hi Wilbaker, could you please test version 1.2.0.4 and close this issue, when successful. Cheers, Markus

MarkusBernhardt commented 11 years ago

Please test with 1.2.0.5. Fixed a silly bug.

wiibaker commented 11 years ago

Works for me. I'll close the issue.

MarkusBernhardt commented 11 years ago

Great!