{"id":16254440,"url":"https://github.com/mantoni/min-webdriver","last_synced_at":"2025-03-16T13:30:49.517Z","repository":{"id":13489730,"uuid":"16180209","full_name":"mantoni/min-webdriver","owner":"mantoni","description":"Pipe scripts to browsers using the Selenium WebDriver protocol","archived":false,"fork":false,"pushed_at":"2023-04-15T17:13:31.000Z","size":286,"stargazers_count":25,"open_issues_count":6,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-07T16:05:37.307Z","etag":null,"topics":["browserify","sauce-labs","selenium","testing"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mantoni.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-01-23T17:48:41.000Z","updated_at":"2022-02-12T17:25:05.000Z","dependencies_parsed_at":"2024-06-18T18:23:29.323Z","dependency_job_id":"7cff077b-8615-42c5-9038-a560cc06a25d","html_url":"https://github.com/mantoni/min-webdriver","commit_stats":{"total_commits":144,"total_committers":10,"mean_commits":14.4,"dds":"0.14583333333333337","last_synced_commit":"c6a1416fed867e0bd79306127966e0bfd763eba4"},"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mantoni%2Fmin-webdriver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mantoni%2Fmin-webdriver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mantoni%2Fmin-webdriver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mantoni%2Fmin-webdriver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mantoni","download_url":"https://codeload.github.com/mantoni/min-webdriver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243815564,"owners_count":20352189,"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":["browserify","sauce-labs","selenium","testing"],"created_at":"2024-10-10T15:22:09.304Z","updated_at":"2025-03-16T13:30:49.230Z","avatar_url":"https://github.com/mantoni.png","language":"JavaScript","readme":"# Minimal WebDriver\n\n[![Build Status]](https://travis-ci.org/mantoni/min-webdriver)\n[![SemVer]](http://semver.org)\n[![License]](https://github.com/mantoni/min-webdriver/blob/master/LICENSE)\n\nPipe scripts to browsers using the Selenium [WebDriver protocol][].\n\n- [SauceLabs][] support\n- [Appium][] support for mobile testing\n- Selenium Server 2 support\n- Concurrent test runs\n- No web server required\n\n## Install\n\n```\nnpm install min-wd\n```\n\n## Usage\n\nPut a config file name `.min-wd` in your project directory:\n\n```\n{\n  \"hostname\": \"localhost\",\n  \"port\": 4444,\n  \"browsers\": [{\n    \"name\": \"internet explorer\",\n    \"version\": \"10\"\n  }, {\n    \"name\": \"chrome\"\n  }]\n}\n```\n\nYou can also have the `.min-wd` file be loaded as a module:\n\n```\nvar hostname = true ? \"localhost\" : \"otherhost\";\n\nmodule.exports = {\n  \"hostname\": hostname,\n  \"port\": 4444,\n  \"browsers\": [{\n    \"name\": \"internet explorer\",\n    \"version\": \"10\"\n  }, {\n    \"name\": \"chrome\"\n  }]\n}\n```\n\n\nAlternatively, add a `webdriver` property with the configs to your\n`package.json` file.\n\nAssuming `my-script.js` contains this:\n\n```js\nconsole.log('Hello %s!', 'browser');\nprocess.exit(0);\n```\n\nUse with [browserify][]:\n\n```\n$ browserify -p min-wd my-script.js\n# internet explorer 9:\nHello browser!\n# chrome *:\nHello browser!\n```\n\nAdditional Selenium capabilities and browser-specific capabilities can be\nspecified with the `capabilities` property:\n\n```\n{\n  \"hostname\": \"localhost\",\n  \"port\": 4444,\n  \"browsers\": [{\n    \"name\": \"chrome\",\n    \"capabilities\": {\n      \"chromeOptions\": {\n        \"args\": [\"--headless\", \"--disable-gpu\"]\n      }\n    }\n  }]\n}\n```\n\n## Shareable configuration package\n\nInspired by [ESLint's shareable configuration package][Eslint Shareable Config],\nthere is the possibility of storing selenium and browser-specific capabilities\nin a separate npm package. This way one config can be shared amongst many npm \npackages instead of them each having their own `.min-wd` file.\n\n### Usage\n\nCreate a npm package and name it using the prefix `min-wd-config-` \n(eg. min-wd-config-myapp).\n\nThe shareable config must contain a js file that exports\nan object with the configuration or a `.min-wd` file. \n\nExample: index.js\n```\nmodule.exports = {\n  \"hostname\": \"localhost\",\n  \"port\": 4444,\n  \"browsers\": [{\n    \"name\": \"chrome\"\n  }]\n}\n```\n\nIn the shareable config's package.json you will need to reference the file \ncontaining the config:\n\n```\n{\n  \"name\": \"min-wd-config-myapp\",\n  \"version\": \"^1.0.0\",\n  \"webdriver\": {\n    \"extends\": \"./index.js\"\n  }\n}\n```\n\nIn the shareable config's dependent, that is the package that consumes the \nshareable config, the config name without the `min-wd-config-` prefix needs to \nbe specified:\n\n```\n{\n  \"name\": \"myapp\",\n  \"webdriver\": {\n    \"extends\": \"myapp\"\n  },\n  \"devDependencies\": {\n    \"min-wd-config-myapp\": \"^1.0.0\"\n  }\n}\n```\n\nWhen using a shareable config and a `.min-wd` file, the latter will take \nprecedence.\n\n\n## SauceLabs\n\nExport your SauceLabs credentials:\n\n```\nexport SAUCE_USERNAME=\"your-user-name\"\nexport SAUCE_ACCESS_KEY=\"your-access-key\"\n```\n\nEnable SauceLabs in your `.min-wd` file:\n\n```\n{\n  \"sauceLabs\": true,\n  \"browsers\": [...]\n}\n```\n\nSee [\"Supported options\"](#supported-options) for additional SauceLabs specific\noptions and [\"SauceLabs on Travis\"](#saucelabs-on-travis) on how to run\nmin-webdriver tests on Travis.\n\n## Appium\n\nNote: This has only be tested on Mac OS X High Sierra with the iOS Simulator so\nfar. If you have successfully tested with other configurations, please file an\nissue so that we can extend the docs.\n\nSetup for iOS Simulator on Mac OS X:\n\n- `npm install -g appium`\n- `brew install carthage`\n- Configure your `.min-wd` file like this:\n\n```\n{\n  \"hostname\": \"localhost\",\n  \"port\": 4723,\n  \"browsers\": [{\n    \"name\": \"Safari\",\n    \"platformName\": \"iOS\",\n    \"platformVersion\": \"11.2\",\n    \"deviceName\": \"iPhone Simulator\"\n  }]\n}\n```\n\n- Run `appium` which should start a server on port 4723\n- Run your tests\n\n## BrowserStack\n\nExport your BrowserStack credentials:\n\n```\nexport BROWSERSTACK_USERNAME=\"your-user-name\"\nexport BROWSERSTACK_ACCESS_KEY=\"your-access-key\"\n```\n\nExample `.min-wd` file:\n\n```\nmodule.exports = {\n  \"hostname\": \"hub-cloud.browserstack.com\",\n  \"port\": 80,\n  \"browsers\": [{\n    \"name\": \"chrome\",\n    \"capabilities\": {\n      \"browser\": \"Chrome\",\n      \"browserstack.user\": process.env.BROWSERSTACK_USERNAME,\n      \"browserstack.key\": process.env.BROWSERSTACK_ACCESS_KEY\n    }\n  }]\n}\n```\n\n## Loading a web page\n\nBy default, min-webdriver will fork a new browser and inject the given script\nstraight away without loading any web page. If you want to run your test cases\nin the context of a web page, you can configure the start page in the `.min-wd`\nfile:\n\n```\n{\n  \"url\": \"http://my-test-page\"\n}\n```\n\n## Mocha Support\n\nTesting with [Mocha][] requires [mocaccino][]:\n\n```\n$ browserify -p mocaccino -p min-wd my-test.js\n```\n\nIf this is your use case, make sure to give [Mochify][] a try.\n\n## Timeouts\n\nThe default timeout for the log polling script is 10 seconds. If you have long\nrunning test cases that don't print anything for more than 10 seconds, you can\nincrease the timeout by adding a `timeout` property to your config:\n\n```\n\"timeout\": 20000\n```\n\n**Notice:** This option is not used if explicitly setting the `asyncPolling`\noption to `false`.\n\n## API\n\nUse min-wd programatically with browserify like this:\n\n```\nvar browserify = require('browserify');\nvar minWd = require('min-wd');\n\nvar b = browserify();\nb.plugin(minWd, { timeout : 0 });\n```\n\n### Supported options\n\n- `wdFile` specify the location of the `.min-wd` config file. Defaults to `.min-wd`.\n- `sauceLabs` whether to run tests with `saucelabs`. Defaults to `false`.\n- `hostname` the host to connect to. Defaults to `localhost`. If `sauceLabs` is\n  `true`, `ondemand.saucelabs.com` is used.\n- `port` the port to connect to. Defaults to `4444`. If `sauceLabs` is `true`,\n  `80` is used.\n- `asyncPolling` whether to use async polling when looking for test results.\n  Defaults to `true`.\n- `timeout` if a script does not respond to log polling calls for this amount\n  of milliseconds, the test run is aborted. Defaults to 10 seconds.\n- `url` the URL to open in each browser. Defaults to no URL.\n- `closeOnSuccess` whether to close browsers on success. Defaults to `true`.\n- `closeOnError` whether to close browsers on error. Defaults to `true`.\n- `browsers` an array of browser config objects, each with these properties:\n    - `name` the name of the browser to launch, e.g. `chrome`, `firefox` or\n      `internet explorer`\n    - `version` the browser version to launch. Use `*` for any.\n    - `url` an optional URL to launch for this browser\n    - `capabilities` additional Selenium capabilities and browser-specific\n      capabilities\n\nSome options are only considered depending on the `asyncPolling` value:\n\n  - `pollingInterval` sets the time interval between test log checks. Only\n    apply if `asyncPolling` is `false`. Defaults to 1000 milliseconds.\n  - `timeout` option won't apply if `asyncPolling` is set to `false` because\n    the test log is checked manually respecting `pollingInterval`.\n\nSauceLabs specific options that only apply if `sauceLabs` is set to `true`:\n\n- `sauceJobName` sets a custom name for the SauceLabs job. If a `package.json`\n  file exists in the current directory, this defaults to the package name.\n- `BUILD_VAR` sets the environment variable name that contains a build number\n  to set, e.g. `TRAVIS_BUILD_NUMBER`.\n\n### SauceLabs on Travis\n\nAssuming you have your linter and headless tests in an npm \"test\" script and\nthe SauceLabs tests in a script called \"wd\", then the SauceLabs builds can be\nused by configuring your `.travis.yml` like this:\n\n```\nlanguage: node_js\nnode_js:\n  - \"0.12\"\n  - \"4.2\"\n\nenv:\n  global:\n    - SAUCE_USERNAME=mantoni\n    - secure: \"your-secured-access-key\"\n\nscript:\n  - 'npm test'\n  - 'if [ \"x$TRAVIS_NODE_VERSION\" = \"x4.2\" ]; then npm run wd; fi'\n```\n\nThis will run `npm test` on Node 0.12 and 4.2 while running the \"wd\" script\nonly in the node 4.2 build.  See the Travis [documentation for encryption\nkeys][TravisKeys] for details about the `secure` config.\n\n## Known issues and solutions\n\n`min-webdriver` injects your script directly into the default page launched by\nthe Selenium driver. In some cases browsers behave strangely in this context.\nWork around this by specifying a URL to a simple web page that is loaded before\nrunning the tests:\n\n```\n{\n  \"browsers\": [{\n    \"name\": \"Internet Explorer\",\n    \"version\": \"9\",\n    \"url\": \"http://my-server/doctype.html\"\n  }]\n}\n```\n\nWith this content in the `doctype.html`:\n\n```html\n\u003c!DOCTYPE html\u003e\u003chtml\u003e\u003chead\u003e\u003cmeta encoding=\"utf-8\"\u003e\u003c/head\u003e\u003cbody\u003e\u003c/body\u003e\u003c/html\u003e\n```\n\nYou can also specify a `\"url\"` for all browser on the root level.\n\nLoading a page before injecting the scripts is solving these issues:\n\n- IE 9 reporting it can't find `JSON` because the Selenium default page makes\n  IE switch to quirks mode\n- Error: `SECURITY_ERR: DOM Exception 18` because setting cookies is not\n  allowed for `file://` URLs\n- Error: `access to the Indexed Database API is denied in this context`\n- localStorage being inaccessible.\n- iOS Simulator does not report anything: Set `asyncPolling: false`\n\n#### Usage with Microsoft Edge browser\n\nTo configure edge use `{ \"name\": \"microsoftedge\" }`. For the time being, MS\nEdge doesn't support `asyncPolling` set to `true`. If you want to test with\nthat browser you must set `asyncPolling` to `false`.\n\n## Compatibility\n\n- Node 0.10, 0.12, 4.x, 5.x\n- Selenium Server 2.39 or later\n\n## License\n\nMIT\n\n[Build Status]: http://img.shields.io/travis/mantoni/min-webdriver.svg\n[SemVer]: http://img.shields.io/:semver-%E2%9C%93-brightgreen.svg\n[License]: http://img.shields.io/npm/l/min-wd.svg\n[WebDriver protocol]: https://code.google.com/p/selenium/wiki/JsonWireProtocol\n[browserify]: http://browserify.org\n[Mocha]: http://mochajs.org/\n[Mochify]: https://github.com/mantoni/mochify.js\n[mocaccino]: https://github.com/mantoni/mocaccino.js\n[TravisKeys]: https://docs.travis-ci.com/user/encryption-keys/\n[SauceLabs]: https://saucelabs.com\n[Appium]: http://appium.io\n[Eslint Shareable Config]: https://eslint.org/docs/user-guide/configuring#using-a-shareable-configuration-package\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmantoni%2Fmin-webdriver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmantoni%2Fmin-webdriver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmantoni%2Fmin-webdriver/lists"}