{"id":18120126,"url":"https://github.com/stoically/webextensions-geckodriver","last_synced_at":"2025-04-14T17:12:18.056Z","repository":{"id":52130711,"uuid":"127550828","full_name":"stoically/webextensions-geckodriver","owner":"stoically","description":"Run your WebExtension with GeckoDriver based on the manifest.json for testing purposes ","archived":false,"fork":false,"pushed_at":"2021-05-07T01:52:20.000Z","size":143,"stargazers_count":13,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-14T17:12:13.572Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stoically.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-31T16:37:43.000Z","updated_at":"2024-03-25T21:24:56.000Z","dependencies_parsed_at":"2022-09-08T08:25:27.042Z","dependency_job_id":null,"html_url":"https://github.com/stoically/webextensions-geckodriver","commit_stats":null,"previous_names":["webexts/webextensions-geckodriver"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stoically%2Fwebextensions-geckodriver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stoically%2Fwebextensions-geckodriver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stoically%2Fwebextensions-geckodriver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stoically%2Fwebextensions-geckodriver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stoically","download_url":"https://codeload.github.com/stoically/webextensions-geckodriver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248923765,"owners_count":21183953,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-01T05:18:32.231Z","updated_at":"2025-04-14T17:12:18.017Z","avatar_url":"https://github.com/stoically.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"### WebExtensions GeckoDriver\n\nWhen testing [WebExtensions](https://developer.mozilla.org/Add-ons/WebExtensions) you might want to automatically load them into Firefox and do functional testing with [geckodriver](https://github.com/mozilla/geckodriver).\n\n### Installation\n\n```\nnpm install --save-dev webextensions-geckodriver\n```\n\n### Usage\n\n```js\nconst webExtensionsGeckoDriver = require('webextensions-geckodriver');\nconst webExtension = await webExtensionsGeckoDriver('/absolute/path/to/manifest.json');\n```\n\nLoads the WebExtension as Temporary Add-on into a new Firefox instance. See [API docs](#api) for more details.\n\n\n### Example\n\nmanifest.json includes\n```\n  \"browser_action\": {\n    \"default_title\": \"Visit Example.com\"\n  },\n  \"applications\": {\n    \"gecko\": {\n      \"id\": \"@examplewebextension\",\n      \"strict_min_version\": \"57.0\"\n    }\n  }\n```\n\nTest could look like this (using `mocha`):\n```js\nconst path = require('path');\nconst assert = require('assert');\n\nconst webExtensionsGeckoDriver = require('webextensions-geckodriver');\nconst {webdriver} = webExtensionsGeckoDriver;\n\nconst manifestPath = path.resolve(path.join(__dirname, './path/to/manifest.json'));\n\ndescribe('Example', () =\u003e {\n  let geckodriver;\n\n  before(async () =\u003e {\n    const webExtension = await webExtensionsGeckoDriver(manifestPath);\n    geckodriver = webExtension.geckodriver;\n  });\n\n  it('should have a Toolbar Button', async () =\u003e {\n    const button = await geckodriver.wait(webdriver.until.elementLocated(\n      // browser_actions automatically have applications.gecko.id as prefix\n      // special chars in the id are replaced with _\n      webdriver.By.id('_examplewebextension-browser-action')\n    ), 1000);\n    assert.equal(await button.getAttribute('tooltiptext'), 'Visit Example.com');\n  });\n\n  after(() =\u003e {\n    geckodriver.quit();\n  });\n});\n```\n\nFull executable example is in the [example directory](example/).\n\n\n### API\n\n#### Exported default function(path[, options])\n\n* *path* `\u003cstring\u003e`, required, absolute path to the `manifest.json` file\n* *options* `\u003cobject\u003e`, optional\n  * *binary* `\u003cstring\u003e`, optional, lets you set the `binary` that is passed to [`fx-runner`](https://github.com/mozilla-jetpack/node-fx-runner). Possible values: `firefox`, `beta`, `aurora`, `nightly`, `firefoxdeveloperedition`. Defaults to: `firefox`.\n  * *autoInstall*, `\u003cboolean\u003e`, optional, if set to `false` the extension will not be installed, you can manually do so later by calling `install`. Defaults to `true`.\n  * *webExt* `\u003cobject\u003e`, optional, lets you overwrite the parameters that get passed into [`web-ext.cmd.build`](https://github.com/mozilla/web-ext#using-web-ext-in-nodejs-code)\n  * *fxOptions* `firefox.Options`, optional, a [`firefox.Options`](https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/firefox_exports_Options.html) that will be passed to the webdriver\n\n\nReturns a Promise that resolves with an initialized `WebExtensionsGeckodriver` instance in case of success, notably with the following properties:\n\n* *geckodriver*, `\u003cobject\u003e`, a new [`selenium-webdriver/firefox`](https://www.npmjs.com/package/selenium-webdriver) instance with previously loaded [`geckodriver`](https://www.npmjs.com/package/geckodriver)\n* *install*, `\u003cfunction\u003e`, returns a Promise that resolves when installing is finished, accepts an options `\u003cobject\u003e`:\n  * *extensionPath*, `\u003cstring\u003e`, optional, path to something that [`installAddon`](https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/firefox_exports_Driver.html) can handle. Defaults to the `web-ext` build extensionPath.\n  * *temporary*, `\u003cboolean\u003e`, optional, whether the WebExt should be installed temporary. Defaults to `true`.\n* *internalUUID*, `\u003cfunction\u003e`, returns a Promise that resolves to the `Internal UUID` of the installed extension\n* *uninstall*, `\u003cfunction\u003e`, returns a Promise that resolves when uninstalling is finished, accepts an optional extensions id as `\u003cstring\u003e`\n\n\n#### Exported property: `webdriver`\n\nReturn value of [`require('selenium-webdriver')`](https://www.npmjs.com/package/selenium-webdriver)\n\n#### Exported property: `firefox`\n\nReturn value of [`require('selenium-webdriver/firefox')`](https://www.npmjs.com/package/selenium-webdriver)\n\n\n### Travis Configuration\n\n```\ndist: xenial\nservices:\n  - xvfb\n\nlanguage: node_js\naddons:\n  firefox: latest\n\nnode_js:\n  - 'lts/*'\n```\n\n### Headless Example\n\n```js\nconst webExtensionsGeckoDriver = require('webextensions-geckodriver');\n\nconst {firefox} = webExtensionsGeckoDriver;\n// or equivalently:\n//   const firefox = require('selenium-webdriver/firefox')\n\nconst fxOptions = new firefox.Options()\n  .headless()\n  .windowSize({height: 1080, width: 1920}) // If you rely on viewport size\n\nwebExtensionsGeckoDriver(manifestPath, {fxOptions})\n```\n\n### JSDOM\n\nIf you're looking for a way to test WebExtensions with JSDOM then [`webextensions-jsdom`](https://github.com/webexts/webextensions-jsdom) might be for you.\n\n### Credits\n\nThanks to [Standard8](https://github.com/Standard8) for the original work in [example-webextension](https://github.com/Standard8/example-webextension).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstoically%2Fwebextensions-geckodriver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstoically%2Fwebextensions-geckodriver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstoically%2Fwebextensions-geckodriver/lists"}