One of our internal applications (written in angularjs) has a special error box appearing if javascript is disabled in the browser (using noscript), similar to the
As far as I understand (with the help of several points raised here), disabling javascript is killing the javascript webdriver itself. Is it true?
Yes. Note that WebDriver itself runs as a Firefox extension, so its code isn't affected by you disabling JavaScript. However, the error message indicates that Selenium is attempting to run some code in the context of the webpage. For that it injects a tag into the webpage and puts the contents of
evaluate.js
into it. Then it waits for that script to set a flag indicating that it is ready - something that never happens of course because scripts aren't running in that webpage.
If yes, what are my options or workarounds?
The important question is what Selenium is trying to run there. Your traceback is merely indicating that some code is calling executeScript()
or executeAsyncScript()
. I couldn't find any implied calls to either method in the Selenium codebase (at least not in any files related to Firefox web driver). Given that Selenium is open source, you should be able to debug it and add a breakpoint on org.openqa.selenium.remote.RemoteWebDriver.executeScript()
and org.openqa.selenium.remote.RemoteWebDriver.executeAsyncScript()
- that way you will actually see the script being executed there. Alternatively, you can also recompile RemoteWebDriver.java
and make it produce debugging output.
Looking into how these methods are implemented, there might also be another way: telling Selenium that JavaScript is disabled. This should work via capabilities:
'javascriptEnabled': false,
According to documentation this capability only works on HTMLUnitDriver, yet Selenium will always consider it and from the source code specifying it for Firefox seems possible. With this capability any calls executing scripts on web pages will fail early.