Selenium Webdrivers: Load Page without any resources

Posted by Biffy on Stack Overflow See other posts from Stack Overflow or by Biffy
Published on 2013-10-29T09:22:48Z Indexed on 2013/10/29 9:53 UTC
Read the original article Hit count: 194

I am trying to prevent Javascript from changing the site's source code I'm testing with Selenium. The problem is, I can't just simply turn Javascript off in the Webdriver, because I need it for a test. Here's what I'm doing for the Firefox Webdriver:

        firefoxProfile.setPreference("permissions.default.image", 2);
        firefoxProfile.setPreference("permissions.default.script", 2);
        firefoxProfile.setPreference("permissions.default.stylesheet", 2);
        firefoxProfile.setPreference("permissions.default.subdocument", 2);

I don't allow Firefox to load any Images, Scripts and Stylesheets. How can I do this with the Internet Explorer Webdriver and the Chrome Webdriver? I have not found any similar preferences. Or is there even a more elegant way to stop the webdrivers from loading the site's JS Files after all? Thank you!

© Stack Overflow or respective owner

Related posts about java

Related posts about JavaScript