我正在尝试使用watir-webdriver和Chrome浏览某些页面。谷歌搜索周围没有任何成功,所以这是我的问题:
我不需要任何图像,因此,为了加快处理速度,我尝试禁用图像加载。
使用firefox,因为我的浏览器相对来说比较省力
profile = Selenium::WebDriver::Firefox::Profile.new
profile['network.image.imageBehavior'] = 2
browser = Watir::Browser.new :firefox, :profile => profile
但是我对chromium没有任何成功。据我了解,您可以通过以下方式设置首选项并传递命令行选项(示例):
prefs = {
:download => {
:prompt_for_download => false,
:default_directory => '/tmp'
},
}
args = ['--start-maximized', '--incognito']
browser = Watir::Browser.new :chrome, :prefs => prefs, :args => args,
没问题。问题是,AFAIK没有命令行选项,也没有偏好来阻止铬中的图像。
任何想法?
我的设置:
我设法通过代理禁用了图像加载以及更多功能,可以选择使用任何浏览器驱动程序。
prefs = {
:profile => {
:managed_default_content_settings => {
:images => 2
}
}
}
b = Watir::Browser.new :chrome, :prefs => prefs
有人解决了这个问题,因为我尝试了不同的方法但仍然无法正常工作