[英]Is it possible to disable loading images (jpg and png only) on Selenium and Chrome webdrive?
In my efforts to improve performance of my selenium testing application I was wondering if it is possible to avoid loading certain files such as images (jpg and png). 在提高硒测试应用程序性能的过程中,我想知道是否有可能避免加载某些文件,例如图像(jpg和png)。 The parameter "--disable-images" disable all images, including "gif", which in my canse can be a google analytics tag, and I must capture that.
参数“ --disable-images”禁用所有图像,包括“ gif”,在我的canse中可以是google Analytics(分析)标签,我必须捕获它。
Yes, you can do it by specifying profile.managed_default_content_settings.image
in ChromeOptions
. 是的,您可以通过在
ChromeOptions
指定profile.managed_default_content_settings.image
来ChromeOptions
。 Example: 例:
chromeOptions = webdriver.ChromeOptions()
prefs = {"profile.managed_default_content_settings.images": 2}
chromeOptions.add_experimental_option("prefs", prefs)
driver = webdriver.Chrome(chrome_options=chromeOptions)
As for only for specific image formats, I don't think it's possible 至于仅特定的图像格式,我认为这是不可能的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.