python - Disabling Javascript after page has been rendered in Selenium Webdriver -
i'm using python. i've seen how can disable javascript in firefox selenium? says create profile load driver profile. want disable javascript after page has been rendered means can't recreate driver.
i've tried following:
browser = selenium.webdriver.firefox() browser.get('http://wwwhatever.com') browser.firefox_profile.set_preference('javascript.enabled', false) browser.firefox_profile.update_preferences()
but this:
print browser.capabilities['javascriptenabled'] true
furthermore, rest of test still acts javascript enabled.
it possible quickjs extension - https://addons.mozilla.org/en-us/firefox/addon/quickjs/?src=search. extension add ctrl+q shortcut disable javascript. here code:
profile = selenium.webdriver.firefoxprofile() profile.add_extension("addon-8753-latest.xpi") #quickjs extension browser = selenium.webdriver.firefox(profile) browser.get('http://wwwhatever.com') #turn of javascript, send ctrl+q body = browser.find_element_by_tag_name("body") body.send_keys(selenium.webdriver.common.keys.keys.control + 'q')
Comments
Post a Comment