我已经尝试过这个方法,但它不起作用。
prefs = {
:profile => {
:managed_default_content_settings => {
:images => 2
}
}
}
Watir::Browser.new :chrome, :prefs => prefs
browser.goto "http://www.example.com"
最佳答案
:prefs
需要是 :options
哈希中的键:
browser = Watir::Browser.new :chrome, options: {prefs: prefs}
专门用于禁用图像:
browser = Watir::Browser.new(
:chrome,
options: {
prefs: {'webkit.webprefs.loads_images_automatically' => false}
}
)
browser.goto('www.google.com')
p browser.image.loaded?
#=> false
关于ruby - 如何使用 Watir 在没有图像的情况下启动 Chrome?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59713168/