Turn off "RHINO USAGE WARNING" for HtmlUnit - htmlunit

I'm using HtmlUnit 2.27 and I currently have the following settings
LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log",
"org.apache.commons.logging.impl.NoOpLog");
java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(Level.OFF);
java.util.logging.Logger.getLogger("org.apache.commons.httpclient").setLevel(Level.OFF);
java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter")
.setLevel(Level.OFF);
java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit.javascript.host.ActiveXObject")
.setLevel(Level.OFF);
java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDocument")
.setLevel(Level.OFF);
java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit.html.HtmlScript").setLevel(Level.OFF);
java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit.javascript.host.WindowProxy")
.setLevel(Level.OFF);
java.util.logging.Logger.getLogger("com.gargoylesoftware").setLevel(Level.OFF);
java.util.logging.Logger.getLogger("org.apache").setLevel(Level.OFF);
But I am still getting Rhino warnings such as below.
RHINO USAGE WARNING: Missed Context.javaToJS() conversion:
Rhino runtime detected object
Anyway to prevent Rhino warnings to be printed?

Related

Is there a way how to set my Cucumber-js to ignore uncaught errors

I am setting up the Cucumber-js (I have migrated Testcafe into Cucumber framework) project which runs well on Chrome and Edge browser. By running on IE 11, the console error causes failing my test scenarios. How to specify in Cucumber-js to ignore uncaught errors? The issue is not reproducible by manual handling or on another browsers as I already mentioned (issue caused by different JQuery version).
I have specified it in
return runner
.src('./test.js')
.screenshots('reports/screenshots/', true)
.browsers(browser)
.run({skipJsErrors: true})
.catch(function(error) {
console.error(error);
});
})
Which works well for me
CucumberJS has no interaction with a browser. It is selenium or protractor that does that kind of operation so it may be better to ask in those StackOverflow communities. I will say that I have not ever seen a browser console error causing browser controlled tests to fail (unless purposefully implemented that way).

AWS Lambda: Calling the invoke API action failed with this message: [object Object]

This question has a few more details, in addition to the report here: AWS Lambda: Calling the Invoke API failed with message: [object Object]
When I try to invoke my Lambda function, by clicking on "Test" button, I see the error reported.
Issue seen on browser: Firefox Nightly 64.0a1 (2018-10-15) (64-bit), on a Windows 10 system.In the browser console, I see this error:
TypeError: asm.js type error: Disabled by 'asmjs' runtime option rusha.min.js
In the Network tab, of the Firefox dev-tools, I see that the invocation returns with a 403 error. The response is :
{"message":"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details."}
Everything works as expected on Microsoft Edge, and Chrome browsers.
Asm might be a red herring, but I can believe AWS might well be using it to speed up their signing. This fits, as the error you're seeing occurs when you try to do something on the AWS Api without the v4 signature being correct.
I notice you're using a nightly build of firefox, so you might well be subject to a known bug &c, or asm.js might be disabled for that platform.
Following the error, I suggest you try going to about:config (to change your firefox configuration), and set javascript.options.asmjs to true.
Failing that, you might have to get off the nightly build or raise a bug report.
This was an issue / bug, that has since been fixed in Firefox Nightly (and should flow into Firefox standard release).
The details of the issue are here: https://bugzilla.mozilla.org/show_bug.cgi?id=1499136
In Firefox's about:config, the key
dom.xhr.standard_content_type_normalization is now set to false by default.

How can I log javascript errors with Poltergeist/Capybara/Rspec?

I'm using Rspec/Capybara with Poltergeist as a driver to write tests for some large web applications.
My issue is that I would like to record the messages that appear on the console, but so far I've been unable to do so.
I am aware of the options js_errors and phantomjs_logger, but I have had some issues with them:
if I set js_errors: false, the file I specify in phantomjs_logger stays empty;
if I set js_errors: true, console.log messages are logged in the file specified in phantomjs_logger, but then almost all my specs fail because of
javascript errors that may not even be relevant to the navigation example I'm testing.
Any idea on how I can save the console messages while not breaking specs on every js error?
CLARIFICATION:
I have no control over the development, my task is to check the stability of the whole stack of the applications in the various environments, accessing from the front-end, so clearing out all the javascript errors is out of the question. The specs I'm writing are also supposed to ignore javascript errors if they don't impair the usage of the interface.
You can't. The PhantomJS client catches javascript error messages and adds them to an array. Then when a command completes, if js_errors == true, that array is checked and if not empty the javascript errors are returned and trigger an error in the test. There is no other API in poltergeist for accessing those errors. It sounds like you need to have a discussion with your manager about the wisdom of just ignoring JS errors if they apparently don't impair usage - it's a potentially dangerous development practice

WebGL apps (Cesium) in headless browser with xvfb

I am trying to run Cesium (http://cesiumjs.org/) with a headless firefox. I also tried slimerjs. In both cases, I am using xvfb, and get this:
[azureuser#myvm.net slimerjs-0.9.5]$ ./slimerjs test.js
Script Error: uncaught exception: RuntimeError: The browser supports WebGL, but initialization failed.
RuntimeError#http://myvm.net/Cesium/Cesium.js:11697:19
Context#http://myvm.net/Cesium/Cesium.js:97405:1
Scene#http://myvm.net/Cesium/Cesium.js:122319:23
CesiumWidget#http://myvm.net/Cesium/Cesium.js:132474:25
#http://myvm.net/:254:22
x.Callbacks/l#http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js:4:24877
x.Callbacks/c.fireWith#http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js:4:25702
.ready#http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js:4:2898
S#http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js:4:551
Stack:
-> undefined: 0
I did look around online, but did not find any satisfactory answer. There is this: Is there a way to run unit test for a WebGL webapp in a headless browser, but it did not generate many replies, and the only answer is not accepted.

Selenium RC test passes when it should fail on verifyTrue(selenium.isTextPresent("string"))

I have a suite of Selenium tests that I created in the Selenium IDE and ported over to Java. In several tests I use the Java equivalent of the verifyTextPresent command to confirm some text on the page (verifyTrue(selenium.isTextPresent())).
I found an spelling error in the text on the page when running the test from the IDE, but the error was not caught when running the test via Selenium RC/TestNG. Here's an example of the code that I have and the text that is causing the problem (spelling error in bold):
Text:
Please correct the errors indicated below.
You need to add a least one restriction.
IDE:
verifyTextPresent | Please correct the errors indicated below.
verifyTextPresent | You need to add at least one restriction.
Java:
verifyTrue(selenium.isTextPresent("Please correct the errors indicated below."));
verifyTrue(selenium.isTextPresent("You need to add at least one restriction."));
Since both versions of the test have the correct text, why is the Selenium RC version not catching the error? Has anyone else had this problem?
The reason why this happens is that the test continues to run after the call to verifyTrue(). Verifications in Selenium catch the exceptions that would be thrown by a failed verification, as opposed to an assertion which throws an exception and causes the test to fail. Because verifications catch exceptions instead of throwing them, the test passes.
At the end of the test, the method checkForVerificationErrors() needs to be called to see if any of the verifications failed. If the method is not called, any verification errors will be ignored and the test will still pass (absent any other problems).
A discussion on the Selenium Google Group about the error itself is here. A discussion about the various verifications vs. assertions is here.
I had a similar problem... My workaround is to use assertTrue() instead of verifyTrue(). I hope it works for you to.

Resources