我想用 Selenium WebDriver Java 激活 Adblocker for Chrome.
I would like to activate Adblocker for Chrome with Selenium WebDriver Java.
怎么做?
你可以使用扩展的 crx 文件或者指向它的安装目录.假设你已经安装了它,你需要添加 ChromeOptions 到你的 new ChromeDriver:
You can either use the crx file of the extension or point to a directory it's installed in. Assuming you have it installed, you'll need to add ChromeOptions to your new ChromeDriver:
ChromeOptions options = new ChromeOptions();
options.addArguments("load-extension=/path/to/extension");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
ChromeDriver driver = new ChromeDriver(capabilities);
请参阅此处了解更多详情和演练.
See here for more details and walkthrough.
要查看您的扩展路径,请导航到 chrome://version 并查看配置文件路径".在该文件夹中查找扩展"文件夹.AdBlock Plus 的扩展 ID 是 cfhdojbkjhnklbpkdaibdccddilifddb.所以路径/到/扩展名应该类似于(Windows):
to see your extensions path, navigate to chrome://version and look at 'Profile Path'. In that folder look for 'Extensions' folder. The extension ID for AdBlock Plus is cfhdojbkjhnklbpkdaibdccddilifddb. So the path/to/extension should be something like (Windows):
C:Users<user>AppDataLocalGoogleChromeUser Data<profile>Extensionscfhdojbkjhnklbpkdaibdccddilifddb
这篇关于如何使用 Selenium WebDriver 在 Chrome 中激活 AdBlocker?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何检测 32 位 int 上的整数溢出?How can I detect integer overflow on 32 bits int?(如何检测 32 位 int 上的整数溢出?)
return 语句之前的局部变量,这有关系吗?Local variables before return statements, does it matter?(return 语句之前的局部变量,这有关系吗?)
如何将整数转换为整数?How to convert Integer to int?(如何将整数转换为整数?)
如何在给定范围内创建一个随机打乱数字的 intHow do I create an int array with randomly shuffled numbers in a given range(如何在给定范围内创建一个随机打乱数字的 int 数组)
java的行为不一致==Inconsistent behavior on java#39;s ==(java的行为不一致==)
为什么 Java 能够将 0xff000000 存储为 int?Why is Java able to store 0xff000000 as an int?(为什么 Java 能够将 0xff000000 存储为 int?)