Selenium + Firefox: enable javascript without using WebDriver

When I open a page with Selenium 2.39.0 and Firefox 26/27, I get the content of the <noscript> tag, so I need to enable javascript somehow. There are tons of materials on how to enable/disable javascript with FirefoxDriver and FirefoxProfile, but I cannot use this approach. Here's why: Selenium fails to open page on localhost

I need to enable javascript when using Selenium "the old way" like this:

browser = new DefaultSelenium("localhost", 4444, "*firefox", "http://localhost/");

How can I do this?


If you're using Firefox, you're best of creating a custom profile within Firefox to use to run your scripts. You can configure the profile to have JavaScript disabled for the duration of the test.

Exit firefox and then in a terminal type "firefox -P" to open the profile manager. You can then create one and switch between them (note, all instances of firefox need to be closed for this to appear). Simply disable JS in the profile you wish to use and you're away!

Alternatively, you could create the profile in your code and disable JS directly using the following code:

FirefoxProfile profile = new FirefoxProfile();
    profile.setPreference("javascript.enabled", false);
    WebDriver driver = new FirefoxDriver(profile);

Need Your Help

Why can't I add a earlier xamarin forms version as a nuget into my Xamarin forms project/android package?

c# android xamarin xamarin.forms

I have this project and I have had some issues with it when I try to debug it as android.

ASP repeater collecting data from radiobuttons

c# radio-button

So I have a Asp repeater that prints out some radiobuttons that a user will use to answer a test. What I need to do is to check which radiobuttons are checked so that I can save them to a XML file....