Skip to content

Instantly share code, notes, and snippets.

@lelouchB
Last active April 2, 2020 13:33
Show Gist options
  • Save lelouchB/c0cd43ff0646489cf05ef678988ba338 to your computer and use it in GitHub Desktop.
Save lelouchB/c0cd43ff0646489cf05ef678988ba338 to your computer and use it in GitHub Desktop.
selenium tests
const { Builder, By, until } = require('selenium-webdriver');
const { Options, Context } = require('selenium-webdriver/firefox');
const addonFileLocation = "D:\React\example\web-ext-artifacts\bookmark_it_-1.1.zip";
(async function example(){
const options = new Options()
.setPreference("extensions.legacy.enabled", true)
.setPreference("xpinstall.signatures.required", false);
const driver = new Builder()
.withCapabilities({ "moz:webdriverClick": true })
.forBrowser("firefox")
.setFirefoxOptions(options)
.build();
try {
await driver.installAddon(addonFileLocation);
} catch (e) {
if (!e.message.includes("must be signed")) {
throw e;
}
console.warn("Warning:", e);
console.warn("Skipping test until environment is fixed.");
return;
}
await driver.setContext(Context.CHROME);
await driver.wait(until.elementLocated(By.id("pageActionButton")));
await driver.wait(
until.elementLocated(By.id("bookmark-it_mozilla_org-browser-action"))
);
await driver.quit();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment