- 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.
推薦閱讀
- 數據通信網絡實踐:基礎知識與交換機技術
- Aptana Studio Beginner's Guide
- Building E-commerce Sites with VirtueMart Cookbook
- 物聯網識別技術
- 智慧城市中的移動互聯網技術
- Spring Cloud微服務架構進階
- PLC、現場總線及工業網絡實用技術速成
- Socket.IO Real-time Web Application Development
- Practical Web Design
- 世界互聯網發展報告·2019
- Microservice Patterns and Best Practices
- The Kubernetes Workshop
- Learning Windows 8 Game Development
- 深入理解Nginx:模塊開發與架構解析
- 圖解物聯網