Skip to content
This repository was archived by the owner on Jul 30, 2024. It is now read-only.

Commit 74807e8

Browse files
committed
added firefox: compatibility
1 parent 73042e1 commit 74807e8

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

extensions/requestly_extension.xpi

2.64 MB
Binary file not shown.

index.js

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,30 @@ function encodeFile(file) {
1515

1616
/**
1717
* Returns base64 encoded Requestly extension which can be added to selenium browser
18+
* @param {"chrome" | "firefox"} browser Name of the browser for which extension is needed
1819
* @returns Encoded Extension
1920
*/
20-
function getRequestlyExtension() {
21-
return encodeFile(
22-
path.join(
23-
__dirname,
24-
CONSTANTS.EXTENSION_FOLDER,
25-
CONSTANTS.REQUESTLY_EXTENSION
26-
)
27-
);
21+
function getRequestlyExtension(browser) {
22+
switch (browser) {
23+
case CONSTANTS.BROWSERS.FIREFOX:
24+
return path.join(
25+
__dirname,
26+
CONSTANTS.EXTENSION_FOLDER,
27+
CONSTANTS.REQUESTLY_FIREFOX_EXTENSION
28+
);
29+
30+
case CONSTANTS.BROWSERS.CHROME:
31+
return encodeFile(
32+
path.join(
33+
__dirname,
34+
CONSTANTS.EXTENSION_FOLDER,
35+
CONSTANTS.REQUESTLY_CHROME_EXTENSION
36+
)
37+
);
38+
39+
default:
40+
throw "Missing Browser Name";
41+
}
2842
}
2943

3044
/**
@@ -36,11 +50,13 @@ const importRequestlySharedList = async (driver, sharedListUrl) => {
3650
const tabs = await driver.getAllWindowHandles();
3751
// Switch to /rules which gets opened after installation of extension because
3852
// The focus is by default on the 1st tab opened.
39-
await driver.switchTo().window(tabs[0]);
40-
// Close the /rules tab
41-
await driver.close();
42-
// Switch to the 1st tab(default)
43-
await driver.switchTo().window(tabs[1]);
53+
if (tabs.length > 1) {
54+
await driver.switchTo().window(tabs[0]);
55+
// Close the /rules tab
56+
await driver.close();
57+
// Switch to the 1st tab(default)
58+
await driver.switchTo().window(tabs[1]);
59+
}
4460
// Open Page Url
4561
await driver.get(sharedListUrl);
4662
// Condition for wait till Import List button is located

0 commit comments

Comments
 (0)