diff --git a/packages/e2e-tests/utils/driverBootstrap.js b/packages/e2e-tests/utils/driverBootstrap.js index 833447187c..b1439ed806 100644 --- a/packages/e2e-tests/utils/driverBootstrap.js +++ b/packages/e2e-tests/utils/driverBootstrap.js @@ -85,51 +85,41 @@ const getChromeBuilder = () => { .setChromeOptions(chromeOpts); }; -const getFirefoxBuilder = () => { +const __getFFOptions = () => { const downloadsDir = getDownloadsDir(); const options = new firefox.Options() - /** - * Firefox disallows unsigned extensions by default. We solve this through a config change - * The proper way to do this is to use the "temporary addon" feature of Firefox - * However, our version of selenium doesn't support this yet - * The config is deprecated and may be removed in the future. - */ - .setPreference('xpinstall.signatures.required', false) - .setPreference('devtools.console.stdout.content', true) - .setPreference('extensions.webextensions.uuids', firefoxUuidMapping) - .setPreference('browser.download.folderList', 2) - .setPreference('browser.download.manager.showWhenStarting', false) - .setPreference('browser.download.dir', downloadsDir) - .setPreference( - 'browser.helperApps.neverAsk.saveToDisk', - 'application/csv, text/csv, application/pdfss, text/csv, application/excel' - ) - .setPreference('browser.download.manager.showAlertOnComplete', false) - .addExtensions(path.resolve(__extensionDir, 'Yoroi.xpi')); + /** + * Firefox disallows unsigned extensions by default. We solve this through a config change + * The proper way to do this is to use the "temporary addon" feature of Firefox + * However, our version of selenium doesn't support this yet + * The config is deprecated and may be removed in the future. + */ + .setPreference('xpinstall.signatures.required', false) + .setPreference('devtools.console.stdout.content', true) + .setPreference('extensions.webextensions.uuids', firefoxUuidMapping) + .setPreference('browser.download.folderList', 2) + .setPreference('browser.download.manager.showWhenStarting', false) + .setPreference('browser.download.dir', downloadsDir) + .setPreference( + 'browser.helperApps.neverAsk.saveToDisk', + 'application/csv, text/csv, application/pdfss, text/csv, application/excel' + ) + .setPreference('browser.download.manager.showAlertOnComplete', false) + .addExtensions(path.resolve(__extensionDir, 'Yoroi.xpi')); if (isHeadless()) { options.addArguments('--headless'); } + return options; +} - if (isLinux()) { - const service = new firefox.ServiceBuilder('/snap/bin/geckodriver').build(); - return new Builder() - .withCapabilities({ - chromeOptions: { - args: ['start-maximized'], - }, - }) - .forBrowser(TargetBrowser.FF) - .setFirefoxOptions(options) - .setFirefoxService(service); - } - +const getFirefoxBuilder = () => { + const options = __getFFOptions(); /** * For Firefox it is needed to use "Firefox for Developers" to load the unsigned extensions * Set the FIREFOX_BIN env variable to the "Firefox for Developers" executable */ options.setBinary(firefoxBin); - return new Builder() .withCapabilities({ chromeOptions: { @@ -140,6 +130,12 @@ const getFirefoxBuilder = () => { .setFirefoxOptions(options); }; +const getFirefoxSession = () => { + const options = __getFFOptions(); + const service = new firefox.ServiceBuilder('/snap/bin/geckodriver').build(); + return firefox.Driver.createSession(options, service); +}; + // getting a builder according to a set browser export const getBuilder = () => { switch (getTargetBrowser()) { @@ -156,7 +152,7 @@ export const getBuilder = () => { }; // getting a driver export const getDriver = () => { - const driver = getBuilder().build(); + const driver = isLinux() && isFirefox() ? getFirefoxSession() : getBuilder().build(); driver.manage().setTimeouts({ implicit: 10000 }); if (isFirefox()) { driver.manage().window().maximize();