In one of our internal applications (written in angularjs), a special error window appears if javascript is disabled in the browser (using noscript ), similar to that in stackoverflow:
I am trying to write an automatic test for it, but with difficulties.
We use a protractor , but I'm sure this is not about that. Here is the protractor configuration file:
'use strict'; var helper = require('./helper.js'); exports.config = { seleniumAddress: 'http://localhost:4444/wd/hub', baseUrl: 'http://localhost:9001', capabilities: helper.getFirefoxProfile(), framework: 'jasmine', allScriptsTimeout: 20000, jasmineNodeOpts: { showColors: true, isVerbose: true, includeStackTrace: true } };
where helper.js :
var q = require('q'); var FirefoxProfile = require('firefox-profile'); exports.getFirefoxProfile = function() { var deferred = q.defer(); var firefoxProfile = new FirefoxProfile(); firefoxProfile.setPreference("javascript.enabled", false); firefoxProfile.encoded(function(encodedProfile) { var capabilities = { 'browserName': 'firefox', 'firefox_profile' : encodedProfile, 'specs': [ '*.spec.js' ] }; deferred.resolve(capabilities); }); return deferred.promise; };
As you can see, we set the javascript.enabled preference for firefox to false , which has proven to work if you manually open about:config in firefox, change it to false - you will see the contents of noscript .
But when I run the tests, I get the following error:
An exception was thrown by org.openqa.selenium.WebDriverException: waiting for error load.js
Here is the full trace .
It uses FYI, selenium 2.44.0 and firefox 33.1.1 .
As far as I understand (with the help of a few points raised here ), disabling javascript kills javascript webdriver itself . It's true? If so, what are my options or workarounds?
Notes:
in the case of chrome, in the past you could disable javascript via the --disable-javascript command line argument , but no more .
this leads to bypass number 0 - switching to chrome to the old version that supports the command line flag - this will not be a proven plan B
setting javascript.enabled=false firefox preferences work with selenium python bindings:
from selenium import webdriver profile = webdriver.FirefoxProfile() profile.set_preference('javascript.enabled', False) driver = webdriver.Firefox(firefox_profile=profile) driver.get('https://my_internal_url.com')
I am open to any suggestions and can provide you with any additional information.
javascript firefox testing selenium-webdriver protractor
alecxe
source share