Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I disable javascript in firefox with selenium?

Tags:

python

How can I add preferences to the browser so it launches without javascript?

like image 260
Kaonashi Avatar asked Dec 13 '25 10:12

Kaonashi


1 Answers

Try setting firefox's profile to disable the javascript:

from selenium import webdriver

fp = webdriver.FirefoxProfile()

fp.set_preference("browser.download.folderList",2)
fp.set_preference("javascript.enabled", False)

browser = webdriver.Firefox(firefox_profile=fp)

To check in the webdriver browser if javascript is enabled do the following:

On the menubar navigate to Firefox > Preferences > Content and the check button for enable javascript should be unchecked. Like the picture shown below.

enter image description here


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!