{"id":15673014,"url":"https://github.com/jaredly/mocha-selenium","last_synced_at":"2025-05-06T22:25:09.065Z","repository":{"id":10731381,"uuid":"12985366","full_name":"jaredly/mocha-selenium","owner":"jaredly","description":"Run selenium tests in parallel using mocha","archived":false,"fork":false,"pushed_at":"2016-07-08T21:58:26.000Z","size":329,"stargazers_count":15,"open_issues_count":2,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-15T07:42:35.665Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jaredly.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-09-20T22:35:15.000Z","updated_at":"2020-02-03T01:23:12.000Z","dependencies_parsed_at":"2022-09-26T17:50:37.290Z","dependency_job_id":null,"html_url":"https://github.com/jaredly/mocha-selenium","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredly%2Fmocha-selenium","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredly%2Fmocha-selenium/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredly%2Fmocha-selenium/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredly%2Fmocha-selenium/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaredly","download_url":"https://codeload.github.com/jaredly/mocha-selenium/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252777849,"owners_count":21802658,"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-10-03T15:35:19.849Z","updated_at":"2025-05-06T22:25:09.039Z","avatar_url":"https://github.com/jaredly.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Maintenance status: low\nI'm not actively using this, and haven't touched it in 3 years. If you have errors, I'm not super likely to be able to reproduce them (am not using selenium actively) but I'm happy to help you debug if you like, and I'm definitely happy to accept Pull Requests.\n\n# Mocha Selenium\nEverything you need for selenium testing in node.js.\n\nThere are two parts: the library and the runner.\n\nThe library provides you with the `setup()` function which returns a driver that is instrumented to make your tests **simple, semantic, and easy to use**. Among other things, it is automatically initialized in a `before()` clause, destroyed in an `after()` clause, and will even fire up an instance of your app \u0026 a webdriver server if you need them!\n\nThe runner is configured with a `selenium.json` file, and will run your mocha test files in series or in parallel, for any number of browsers. Installing it with `npm install -g mocha-selenium` will give you the `mocha-selenium` command on your path.\n\n### The Library\nHas a bunch of options. Some of the options are default to ENV variables if they are present. [Read the docs](http://jaredly.github.io/mocha-selenium/#section-2) for a thorough description.\n\nOptionally if you are using the promise webdriver or promiseChain webdriver supported by [wd](https://github.com/admc/wd#q-promises--chaining), you can pass a `webdriverType` to the setup options object. You can use either 'promise' or 'promiseChain' as the string, if not passed the default webdriver will be used.\n\nHere's an example:\n```js\nvar expect = require('expect.js')\n  , b = require('mocha-selenium').setup(\"Login Page\", {\n      appDir: path.dirname(__dirname),\n      lastShot: \"failed\",\n      webdriverType: 'promiseChain'  // OPTIONAL\n    });\n\ndescribe('The login page', function () {\n  this.timeout(20 * 1000)\n  before(function (done) {\n    b.get(b.baseUrl + '/login', done)\n  })\n  it('should work', function (done) {\n    function fail(err) {\n      b.haltChain()\n      done(err)\n    }\n    b.chain({onError: fail})\n     .fillInForm('.loginForm', {\n       username: 'jsmith',\n       password: '1830'\n     })\n     .clickByCss('.loginForm button.submit')\n     // make sure we were redirected to the account page\n     .url(function (err, url) {\n       if (err) return fail(err)\n       expect(url).to.match(/\\/account$/)\n       done()\n     })\n  })\n})\n```\n\n### Convenience functions added to the driver\nIn addition to the normal\n[wd methods](https://github.com/admc/wd/#supported-methods), there are\nthe following:\n\n#### General Methods\n\n##### `ensureCookie(name, value, done(err))`\nOn the current page, if the cookie by the name of `name` with value\n`value` does not exist, set the cookie and refresh the page.\n\nIf value is a function, it is called with the current value of the\ncookie. If it returns a value other than the current cookie value, the\ncookie is set to that value.\n\n##### `fillInForm(data, [formSelector,] done(err))`\nData is a map of `\"input name\": \"value to type\"`. If `formSelector` is\ngiven, only inputs that are children of the given selector will be\nfilled in. Otherwise, the first input in the document with the given\n`name` will be populated.\n\n##### `rel(url, done(err))`\n= `b.get(b.baseUrl + url, done)`.\n\n#### Element-specific methods\nThe following suffixes are available for these methods, mirroring the `wd` library:\n\nByClassName, ByCssSelector, ById, ByName, ByLinkText, ByPartialLinkText, ByTagName, ByXPath, ByCss.\n\nI will use the `ByCss` suffix for demonstration.\n\n- textByCss(selector, done(err, text, element))\n- visibleByCss(selector, done(err, isVisible, element))\n- valueByCss(selector, done(err, value, element))\n- clickByCss(selector, done(err, element))\n- waitAndGet(selector, timeout, done(err, element))\n- waitAndClickByCss(selector, timeout, done(err, element))\n\n### The Runner\nRun your mocha selenium tests in parallel in mutliple browsers.\n\n#### Usage\n\n```\n  Usage: mocha-selenium [options]\n\n  Options:\n\n    -h, --help               output usage information\n    -V, --version            output the version number\n    -e, --environment [env]  Pick the environment to run (host + browsers). Default: local\n    -p, --parallel           Run the tests in parallel. Default: false\n    -c, --config [file]      Specify the config file. Default: ./selenium.json\n```\n\n##### Config\n\n```javascript\n{\n  files: // filename or glob, or list of filenames or globs\n  envs: { // a map of [envname] to an environment definition.\n    local: [browserdef, ...] OR {\n      browsers: [browserdef, ...],\n      inherits: // name or list of names of other environemnts. Their\n                // browserdefs will be appended to the current env.\n      // if no hostname is given, mocha-selenium will start its own\n      // selenium drivers. Currently phantomjs and chrome are supported\n      hostname: \"ondemand.saucelabs.com\",\n      port: 80,\n      auth: {\n        type: 'plain',\n        username: 'MyName',\n        password: 'secret'\n      } OR {\n        type: 'env', // the username and password are environmental variables\n        username: 'SAUCE_USERNAME',\n        password: 'SAUCE_ACCESS_KEY'\n      }\n    },\n    otherenv: ...,\n    ...\n  }\n}\n```\n\n#### Browserdef:\n\n```\n[\"browsername\", \"version\", \"platform\"]\n\nex:\n[\"internet explorer\", \"8\", \"Windows XP\"]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredly%2Fmocha-selenium","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaredly%2Fmocha-selenium","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredly%2Fmocha-selenium/lists"}