I set the following settings on the webdriver to disable javascript when starting Firefox, but the settings do not take effect.
from selenium import webdriver
profile=webdriver.FirefoxProfile()
profile.set_preference("javascript.enabled", False)
browser=webdriver.Firefox(firefox_profile=profile)
If you look at the values in Firefox from about:config
, the javascript.enabled
item is true
.
Double-click javascript.enabled
on the Firefox about:config
screen to false
, but you can't manually switch to false
every time you take a test
Could you tell me how I can specify the value of javascript.enabled
on the python side?
The versions are as follows:
python 3.5.1
selenium 3.3.3
Firefox 51.0.1 (32-bit)
Windows 8.1
browser.get('about:config')
sleep(3)
browser.find_element_by_id('warningButton').click()
browser.find_element_by_id('about-config-search').send_keys('javascript.enabled')
sleep(3)
browser.find_element_by_class_name('button-toggle') .click()
© 2024 OneMinuteCode. All rights reserved.