- Selenium WebDriver 3 Practical Guide
- Unmesh Gundecha Satya Avasarala
- 118字
- 2021-08-13 16:08:15
Adding ChromeExtensions
Similar to Firefox, we can add extensions to the Chrome browser by specifying the location of the extension. We can add Packed (.crx file) or Unpacked (folder) extensions using the ChromeOptions class.
To add a Packed extension, we need to call the addExtension() method:
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addExtensions(new File("/path/to/extension.crx"));
ChromeDriver driver = new ChromeDriver(chromeOptions);
To add an Unpacked extension, we need to use the addArguments() method, which will load the extension reading the specified folder while launching the Chrome binary. This is done as follows:
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("load-extension=/path/to/extension");
ChromeDriver driver = new ChromeDriver(chromeOptions);
Similarly, you can use Chrome options to add more extensions, arguments, and Binaries to your Chrome browser.
推薦閱讀
- 微商之道
- Application Development with Qt Creator(Second Edition)
- 物聯(lián)網(wǎng)工程規(guī)劃技術(shù)
- C++黑客編程揭秘與防范
- Building E-commerce Sites with VirtueMart Cookbook
- 物聯(lián)網(wǎng)安全與深度學(xué)習(xí)技術(shù)
- 物聯(lián)網(wǎng)時(shí)代
- 物聯(lián)網(wǎng)技術(shù)與應(yīng)用
- IPv6網(wǎng)絡(luò)切片:使能千行百業(yè)新體驗(yàn)
- Mastering Dart
- WordPress Web Application Development
- OMNeT++與網(wǎng)絡(luò)仿真
- Getting Started with Memcached
- 一本書讀懂TCP/IP
- 趣話通信:6G的前世、今生和未來(lái)