简体   繁体   中英

Selenium - Geckodriver (Firefox) load unpacked extension

I coded my own extension and I want to add it to geckodriver.

The important thing is I need to add it unpacked as I did for chromedriver.

options.addArguments("--load-extension=" + System.getProperty("user.dir") + "/base/chrome-extension");

Is it possible?

If unpacked is not possible, then, can I install it with creating an archive for that?

I think you want to use Augmenter as mentioned in this issue .

The following is an example provided in this webpage with MIT license :

driver.setFileDetector(new LocalFileDetector());
WebDriver augmentedDriver = new Augmenter().augment(driver);
String id = ((HasExtensions) augmentedDriver).installExtension(Paths.get("src/test/resources/ninja_saucebot-1.0-an+fx.xpi"));

driver.get("https://www.saucedemo.com");
Assertions.assertTrue(driver.findElements(By.className("bot_column2")).size() > 0);
((HasExtensions) augmentedDriver).uninstallExtension(id);

driver.navigate().refresh();
Assertions.assertEquals(0, driver.findElements(By.className("bot_column2")).size());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM