How to disable javascript in Chrome Driver Selenium Python

前端 未结 4 1947
不知归路
不知归路 2020-12-16 08:00

How can I disable Java Script in Selenium\'s Chrome Driver using python

4条回答
  •  温柔的废话
    2020-12-16 08:30

    It's Really easy ! Just try this code !

    from selenium.webdriver.chrome.options import Options

    from selenium.webdriver.chrome.options import Options
    chrome_options = Options()
    chrome_options.add_experimental_option( "prefs",{'profile.managed_default_content_settings.javascript': 2})
    chrome = webdriver.Chrome('chromedriver',chrome_options=chrome_options)
    chrome.get('http://stackoverflow.com/')
    

    If you want to disable Images, just replace javascript with image.

提交回复
热议问题