Selenium WebDriver (Firefox): dynamically disable Javascript -


i know can use firefox profiles disable javascript. example, see enable/disable javascript using selenium webdriver.

however, have case need javascript enabled in order me log in page, want javascript disabled after logged in, when page_source, returns dom if javascript has not run. key login page requires javascript. possible dynamically control whether javascript on or off in selenium webdriver?

i suggest not dynamically disable javascript functionality of webdriver written in javascript , may give unexpected results sometimes. better use firefox profiles disable it, have written code may disable during runtime.

webdriver driver = new firefoxdriver(); driver.get("about:config"); actions act = new actions(driver); act.sendkeys(keys.return).sendkeys("javascript.enabled").perform(); thread.sleep(1000); act.sendkeys(keys.tab).sendkeys(keys.return).sendkeys(keys.f5).perform(); 

if using selenium ide, can refer: http://thom.org.uk/2006/03/12/disabling-javascript-from-selenium/ well.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -