如何在自动化脚本中使用Chrome中的广告? [英] how to allow ads in chrome in my automation script?
本文介绍了如何在自动化脚本中使用Chrome中的广告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个google登录方案,
I have a google login scenario ,
- 打开网站并单击Google登录
- 打开Google弹出窗口以添加电子邮件,然后通过然后单击登录
预期:我应该登录该网站
Expected: I should log in to the website
实际:除非开放网站设置并允许广告,否则我无法登录
Actual: I can not log in unless the open site setting and allow ads
因此,有任何方法可以添加代码以在运行脚本期间允许广告
so is there any way to add code to allow ads during running the script
推荐答案
Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("profile.managed_default_content_settings.ads", 1);
chromeOptions.setExperimentalOption("prefs", prefs);
使用首选项,请参阅以下所有支持的首选项:
use preference , see all supported pref at :
注意:无头浏览器不支持首选项
Note: preference is not supported for headless browser
截至2021年2月
https://bugs.chromium.org/p/chromedriver/issues/detail?id = 1925
无头Chrome不支持偏好设置.
Headless chrome doesn't support preferrences setting .
这篇关于如何在自动化脚本中使用Chrome中的广告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文