Skip to content

Commit

Permalink
a new approach for FF on ubuntu
Browse files Browse the repository at this point in the history
  • Loading branch information
Nebyt committed Jul 17, 2024
1 parent dd53f9a commit 901f317
Showing 1 changed file with 30 additions and 34 deletions.
64 changes: 30 additions & 34 deletions packages/e2e-tests/utils/driverBootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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()) {
Expand All @@ -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();
Expand Down

0 comments on commit 901f317

Please sign in to comment.