Disable images in Selenium Google ChromeDriver

后端 未结 7 1424
悲哀的现实
悲哀的现实 2020-12-16 13:58

How does one disable images in Google chrome when using it through Selenium and c#?

I\'ve attempted 6 ways and none worked. I\'ve even tried the answer on this Stack

7条回答
  •  南笙
    南笙 (楼主)
    2020-12-16 14:42

    You should use --blink-settings instead of --disable-images by:

    options.add_argument('--blink-settings=imagesEnabled=false')
    

    which also works in headless mode. Setting profile doesn't work in headless mode. You can verify it by screenshot:

    driver.get_screenshot_as_file('headless.png')
    

    Note: I was using python with selenium, but I think it should be easy to transfer to c#.

提交回复
热议问题