diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index a74c26b..0000000 --- a/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -/lib/**/*.js binary - diff --git a/.gitignore b/.gitignore deleted file mode 100644 index ad826dc..0000000 --- a/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -/bin/chromedriver -/bin/selenium.jar - -/node_modules -/npm-debug.log - -/test/*_log diff --git a/.testiumrc b/.testiumrc deleted file mode 100644 index 565ff10..0000000 --- a/.testiumrc +++ /dev/null @@ -1,13 +0,0 @@ -launch = true -logDirectory = ./test/integration_log -screenshotDirectory = ./test/integration_log/screenshots - -[app] -command = testium-example-app -timeout = 1000 - -[proxy] -port = 4445 - -[repl] -module = coffee-script/repl diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index acee9de..0000000 --- a/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -language: node_js -node_js: - - '4' -env: - - CXX=g++-4.8 -addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-4.8 diff --git a/API.md b/API.md deleted file mode 100644 index aa42544..0000000 --- a/API.md +++ /dev/null @@ -1,3 +0,0 @@ -# Testium API - -Please read the official [Testium API docs](http://testiumjs.com/api/). diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 63eabf4..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,22 +0,0 @@ -3.3.1 ------ -* Fix repl after testium-core switch - @jkrems - https://github.com/groupon/testium/pull/179 -* [doc] Update element documentation - @EndangeredMassa - https://github.com/groupon/testium/pull/177 -* [dox] Fix getElementOrNull example to use right method - @jkrems - https://github.com/groupon/testium/pull/175 -* Add publishConfig.registry - @jkrems - https://github.com/groupon/testium/pull/174 - -3.3.0 ------ -* Make tests pass without TTY - @jkrems - https://github.com/groupon/testium/pull/173 -* Add API docs for `getElementOrNull` - @jkrems - https://github.com/groupon/testium/pull/172 -* Switch to `testium-core` and `testium-driver-sync` - @jkrems - https://github.com/groupon/testium/pull/172 - - Adds support for `waitForElementNotExist` -* Use assert.match instead of truthy - @khoomeister - https://github.com/groupon/testium/pull/170 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index f5cf2b6..0000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,57 +0,0 @@ -# Contributor Code of Conduct - -As contributors and maintainers of this project, -we pledge to respect all people who contribute through reporting issues, -posting feature requests, -updating documentation, -submitting pull requests or patches, -and other activities. - -We are committed to making participation in this project -a harassment-free experience for everyone, -regardless of level of experience, -gender, -gender identity and expression, -sexual orientation, -disability -personal appearance, -body size, -race, -ethnicity, -age, -or religion. - -Examples of unacceptable behavior by participants include -the use of sexual language or imagery, -derogatory comments or personal attacks, -trolling, -public or private harassment, -insults, -or other unprofessional conduct. - -Project maintainers have the right and responsibility to -remove, -edit, -or reject comments, -commits, -code, -wiki edits, -issues, -and other contributions -that are not aligned to this Code of Conduct. -Project maintainers who do not follow the Code of Conduct -may be removed from the project team. - -This code of conduct applies both within project spaces -and in public spaces -when an individual is representing the project or its community. - -Instances of abusive, harassing, or otherwise unacceptable behavior -may be reported by opening an issue -or contacting one or more of the project maintainers. - -This Code of Conduct is adapted from the -[Contributor Covenant](http://contributor-covenant.org), -version 1.1.0, available at -[http://contributor-covenant.org/version/1/1/0/](http://contributor-covenant.org/version/1/1/0/). - diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 7cb3ea9..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,48 +0,0 @@ -# Contribution Guide - -Please follow this guide when -creating issues or pull requests. - -## Code of Conduct - -The [Code of Conduct](CODE_OF_CONDUCT.md) -will be enforced in all project spaces. -Please read it -so that you know what kind of behavior -is expected here. - -## Reporting a Bug - -Before reporting a bug, -make sure you are using the latest versions of -testium and the browsers that expose the bug. - -When reporting a bug with testium, -please provide a minimal test case. -This can be a gist, -inline in the description, -or in the form of a pull request -that includes a failing test. - -If you are contributing a bug fix, -make sure it has a passing test -in your pull request. - -## Adding a Feature - -Adding currently unimplemented WebDriver calls -will always be considered. -Eventually, testium should support -all of the WebDriver calls in some way. -In order to implement these, -you must first add them to -[webdriver-http-sync](https://github.com/groupon/webdriver-http-sync). - -Before implementing features other than WebDriver calls, -try to make sure that -(1) no one else is currently working on that and -(2) you have checked with the maintainers -that this is something they would like to see. - -All features should have tests. - diff --git a/Makefile b/Makefile deleted file mode 100644 index 58f2d6d..0000000 --- a/Makefile +++ /dev/null @@ -1,82 +0,0 @@ -default: build - -setup: - npm install - -.PHONY: test -test: test-screenshot test-missing-selenium test-start-timeout test-no-app test-cleanup test-integration - -test-integration: build - @echo "# Integration Tests #" - @./node_modules/.bin/mocha test/integration - @echo "" - @echo "" - -test-screenshot: build - @echo "# Automatic Screenshot Tests #" - @./node_modules/.bin/mocha test/screenshots.test.coffee - @echo "" - @echo "" - -test-start-timeout: build - @echo "# Start Timeout Tests #" - @./node_modules/.bin/mocha test/start_timeout.test.coffee - @echo "" - @echo "" - -test-missing-selenium: build - @echo "# Missing Selenium Tests #" - @./node_modules/.bin/mocha test/missing_selenium.test.coffee - @echo "" - @echo "" - -test-no-app: build - @echo "# No App Tests #" - @./node_modules/.bin/mocha test/no_app.test.coffee - @echo "" - @echo "" - -test-cleanup: build - @echo "# Cleanup Tests #" - @./node_modules/.bin/mocha test/cleanup.test.coffee - @echo "" - @echo "" - -download-selenium: - ./cli.js --download-selenium - -firefox: build download-selenium - @testium_browser=firefox make test-integration - -chrome: build download-selenium - @testium_browser=chrome make test-integration - -phantomjs: build - @testium_browser=phantomjs make test-integration - -test-integration-all: phantomjs firefox chrome - -build: - @./node_modules/.bin/coffee -cbo lib src - @./node_modules/.bin/npub prep src - -watch: - @./node_modules/.bin/coffee -cwbo lib src - -force-update: - @./cli.js --force-update - -prepublish: - ./node_modules/.bin/npub prep - -clean: - @rm -rf lib - @rm -rf bin/chromedriver bin/selenium.jar - @rm -rf test/integration_log - @rm -rf test/screenshot_integration_log - -# This will fail if there are unstaged changes in the checkout -test-checkout-clean: - git diff --exit-code - -all: setup clean build force-update test test-checkout-clean diff --git a/README.md b/README.md index f50b2a0..1196988 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,14 @@ -# Testium [![travis-ci build](https://travis-ci.org/groupon/testium.svg?branch=master)](https://travis-ci.org/groupon/testium) +[DEPRECATED] Please use a testing interface + a testium driver -Testium is a testing library focused on providing a simple, -but effective, -tool for testing your web applications -in different browsers (via Selenium) -and headlessly (via PhantomJS). +Test interface +* [testium-mocha][testium-mocha] -## Usage +Testium drivers -This particular module bundles a few different testium libraries together in a fashion -that is no longer recommended. Please instead use a testing interface modules + one -of the testium drivers, e.g: +* [testium-driver-sync][testium-driver-sync] +* [testium-driver-wd][testium-driver-wd] -https://github.com/testiumjs/testium-mocha and https://github.com/testiumjs/testium-driver-wd - -``` -$ npm install --save-dev testium-mocha testium-driver-wd -``` - -```javascript -const { browser } = require('testium-mocha'); - -describe('something', () => { - before(browser.beforeHook({ driver: 'wd' })); - - it('works', () => browser.loadPage('/')); -}); -``` - -## API Docs - -For full API documentation, see the [Testium API Docs](http://testiumjs.com/api/) +[testium-core]: https://github.com/testiumjs/testium-core +[testium-mocha]: https://github.com/testiumjs/testium-mocha +[testium-driver-wd]: https://github.com/testiumjs/testium-driver-wd +[testium-driver-sync]: https://github.com/testiumjs/testium-driver-sync diff --git a/cli.js b/cli.js deleted file mode 100755 index 50cba5b..0000000 --- a/cli.js +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env node -require('./lib/cli'); diff --git a/lib/cli/console.js b/lib/cli/console.js deleted file mode 100644 index 34701a3..0000000 --- a/lib/cli/console.js +++ /dev/null @@ -1,149 +0,0 @@ -// Generated by CoffeeScript 1.9.3 - -/* -Copyright (c) 2014, Groupon, Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -Neither the name of GROUPON nor the names of its contributors may be -used to endorse or promote products derived from this software without -specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -var WELCOME_MESSAGE, _nodeModulePaths, _resolveFilename, collectPublicMethods, collectPublicMethodsDeep, config, exportToContext, getBrowser, getConfig, getMethods, path, prepareRequireExtensions, ref, ref1; - -WELCOME_MESSAGE = "WebDriver repl!\nMethods are available in scope. Try: navigateTo('http://google.com')\nType `.methods` to see what's available."; - -ref = require('module'), _resolveFilename = ref._resolveFilename, _nodeModulePaths = ref._nodeModulePaths; - -path = require('path'); - -ref1 = require('testium-core'), getConfig = ref1.getConfig, getBrowser = ref1.getBrowser; - -config = getConfig(); - -collectPublicMethods = function(obj) { - var method, methods, prop; - methods = []; - for (prop in obj) { - method = obj[prop]; - if (typeof method === 'function' && prop[0] !== '_') { - methods.push(prop); - } - } - return methods; -}; - -collectPublicMethodsDeep = function(obj) { - var proto; - if (obj == null) { - return []; - } - proto = Object.getPrototypeOf(obj); - return collectPublicMethods(obj).concat(collectPublicMethodsDeep(proto)); -}; - -getMethods = function(browser) { - var methods; - methods = collectPublicMethodsDeep(browser); - return methods.sort().join(', '); -}; - -exportToContext = function(browser, context) { - var methods; - context.browser = browser; - context.assert = browser.assert; - methods = collectPublicMethodsDeep(browser); - return methods.forEach(function(method) { - return context[method] = browser[method].bind(browser); - }); -}; - -prepareRequireExtensions = function(pretendModule, replModule) { - var COFFEE, REDUX, coffeeModule; - REDUX = /coffee-script-redux(?:\/lib)?\/repl(?:\.js)?$/; - if (REDUX.test(replModule)) { - coffeeModule = _resolveFilename('coffee-script-redux/register', pretendModule, false); - require(coffeeModule); - } - COFFEE = /coffee-script(?:\/lib)?\/repl(?:\.js)?$/; - if (COFFEE.test(replModule)) { - coffeeModule = _resolveFilename('coffee-script/register', pretendModule, false); - return require(coffeeModule); - } -}; - -module.exports = function() { - var Repl, browserName, pretendFilename, pretendModule, replModule; - browserName = config.browser; - console.error("Preparing " + browserName + "..."); - pretendFilename = path.resolve(config.root, 'repl'); - pretendModule = { - filename: pretendFilename, - paths: _nodeModulePaths(pretendFilename) - }; - replModule = _resolveFilename(config.repl.module, pretendModule, false); - prepareRequireExtensions(pretendModule, replModule); - Repl = require(replModule); - return getBrowser({ - useApp: false - }).done(function(browser) { - var closeBrowser, startRepl; - closeBrowser = function() { - return browser.close(function(error) { - if (error == null) { - return; - } - error.message = error.message + " (while closing browser)"; - throw error; - }); - }; - startRepl = function() { - var repl; - repl = Repl.start({ - prompt: browserName + "> " - }); - exportToContext(browser, repl.context); - repl.on('exit', function() { - return browser.close(function() { - return process.exit(0); - }); - }); - return repl.defineCommand('methods', { - help: 'List available methods', - action: function() { - repl.outputStream.write(getMethods(browser)); - return repl.displayPrompt(); - } - }); - }; - process.on('exit', closeBrowser); - process.on('uncaughtException', function(error) { - closeBrowser(); - throw error; - }); - console.error(WELCOME_MESSAGE); - return startRepl(browser); - }); -}; diff --git a/lib/cli/index.js b/lib/cli/index.js deleted file mode 100644 index 213d019..0000000 --- a/lib/cli/index.js +++ /dev/null @@ -1,58 +0,0 @@ -// Generated by CoffeeScript 1.9.3 - -/* -Copyright (c) 2014, Groupon, Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -Neither the name of GROUPON nor the names of its contributors may be -used to endorse or promote products derived from this software without -specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -var BIN_PATH, USAGE, config, getConfig, path; - -path = require('path'); - -getConfig = require('testium-core').getConfig; - -USAGE = 'Usage: testium [browser | --update-selenium | --force-update | --help]'; - -BIN_PATH = path.resolve(__dirname, '..', '..', 'bin'); - -config = getConfig(); - -if (config['update-selenium'] || config['download-selenium']) { - require('selenium-download').update(BIN_PATH, function() { - return process.exit(0); - }); -} else if (config['force-update']) { - require('selenium-download').forceUpdate(BIN_PATH, function() { - return process.exit(0); - }); -} else if (config['help']) { - console.log(USAGE); -} else { - (require('./console'))(); -} diff --git a/lib/testium.js b/lib/testium.js deleted file mode 100644 index 422a102..0000000 --- a/lib/testium.js +++ /dev/null @@ -1,46 +0,0 @@ -// Generated by CoffeeScript 1.9.3 - -/* -Copyright (c) 2014, Groupon, Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -Neither the name of GROUPON nor the names of its contributors may be -used to endorse or promote products derived from this software without -specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -var getBrowser, getTestium, ref; - -ref = require('testium-core'), getBrowser = ref.getBrowser, getTestium = ref.getTestium; - -exports.getBrowser = function(options, callback) { - if (typeof options === 'function') { - callback = options; - options = {}; - } - return getBrowser(options).nodeify(callback); -}; - -exports.getTestium = getTestium; diff --git a/mocha.js b/mocha.js deleted file mode 100644 index 57693a8..0000000 --- a/mocha.js +++ /dev/null @@ -1,33 +0,0 @@ -/* -Copyright (c) 2014, Groupon, Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -Neither the name of GROUPON nor the names of its contributors may be -used to endorse or promote products derived from this software without -specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -module.exports = require('testium-mocha'); diff --git a/package.json b/package.json deleted file mode 100644 index 97d356f..0000000 --- a/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "testium", - "version": "3.3.1", - "description": "Synchronous integration testing with Node.js bindings for WebDriver", - "license": "BSD-3-Clause", - "keywords": [ - "testing", - "selenium", - "webdriver" - ], - "homepage": "https://github.com/groupon-testium/testium", - "bugs": { - "url": "https://github.com/groupon-testium/testium/issues" - }, - "repository": { - "type": "git", - "url": "git://github.com/groupon-testium/testium" - }, - "author": { - "name": "Sean Massa", - "email": "endangeredmassa@gmail.com" - }, - "publishConfig": { - "registry": "https://registry.npmjs.org", - "license": { - "exclude": [ - "cli.js", - "lib", - "test" - ] - } - }, - "main": "lib/testium.js", - "bin": "cli.js", - "scripts": { - "test": "make all" - }, - "engines": { - "node": ">=0.10.16" - }, - "dependencies": { - "assertive": "^1.4.0", - "debug": "^2.1.0", - "lodash": "^4.17.15", - "mkdirp": "~0.5.0", - "selenium-download": "^2.0.0", - "testium-core": "^1.3.0", - "testium-driver-sync": "^2.1.0", - "testium-mocha": "^1.0.0" - }, - "devDependencies": { - "coffee-script": "1.9.3", - "mocha": "^2.3.3", - "npub": "^2.2.0", - "rimraf": "^2.2.8", - "testium-example-app": "^2.0.0" - } -} diff --git a/src/cli/console.coffee b/src/cli/console.coffee deleted file mode 100644 index c212da8..0000000 --- a/src/cli/console.coffee +++ /dev/null @@ -1,131 +0,0 @@ -### -Copyright (c) 2014, Groupon, Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -Neither the name of GROUPON nor the names of its contributors may be -used to endorse or promote products derived from this software without -specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -### - -WELCOME_MESSAGE = """ -WebDriver repl! -Methods are available in scope. Try: navigateTo('http://google.com') -Type `.methods` to see what's available. -""" - -{_resolveFilename, _nodeModulePaths} = require 'module' -path = require 'path' - -{getConfig, getBrowser} = require 'testium-core' - -config = getConfig() - -collectPublicMethods = (obj) -> - methods = [] - for prop, method of obj - if typeof method == 'function' && prop[0] != '_' - methods.push(prop) - methods - -collectPublicMethodsDeep = (obj) -> - return [] unless obj? - proto = Object.getPrototypeOf(obj) - collectPublicMethods(obj).concat( - collectPublicMethodsDeep(proto) - ) - -getMethods = (browser) -> - methods = collectPublicMethodsDeep browser - methods.sort().join(', ') - -exportToContext = (browser, context) -> - context.browser = browser - context.assert = browser.assert - methods = collectPublicMethodsDeep browser - methods.forEach (method) -> - context[method] = browser[method].bind(browser) - -prepareRequireExtensions = (pretendModule, replModule) -> - # This hack allows using mixins written in coffee-script - # It won't actually change anything in terms of require extensions - # since the coffee-script repl will register the extension anyhow. - REDUX = /coffee-script-redux(?:\/lib)?\/repl(?:\.js)?$/ - if REDUX.test(replModule) - coffeeModule = - _resolveFilename 'coffee-script-redux/register', pretendModule, false - require coffeeModule - - COFFEE = /coffee-script(?:\/lib)?\/repl(?:\.js)?$/ - if COFFEE.test(replModule) - coffeeModule = - _resolveFilename 'coffee-script/register', pretendModule, false - require coffeeModule - -module.exports = -> - browserName = config.browser - console.error "Preparing #{browserName}..." - - # Hack for resolving modules correctly relative to appDirectory - pretendFilename = path.resolve config.root, 'repl' - pretendModule = { - filename: pretendFilename - paths: _nodeModulePaths pretendFilename - } - - replModule = _resolveFilename config.repl.module, pretendModule, false - - prepareRequireExtensions pretendModule, replModule - - Repl = require replModule - - getBrowser(useApp: false).done (browser) -> - closeBrowser = -> - browser.close (error) -> - return unless error? - error.message = "#{error.message} (while closing browser)" - throw error - - startRepl = -> - repl = Repl.start { - prompt: "#{browserName}> " - } - exportToContext browser, repl.context - repl.on 'exit', -> - browser.close -> process.exit(0) - repl.defineCommand 'methods', { - help: 'List available methods' - action: -> - repl.outputStream.write getMethods browser - repl.displayPrompt() - } - - process.on 'exit', closeBrowser - process.on 'uncaughtException', (error) -> - closeBrowser() - throw error - - console.error WELCOME_MESSAGE - startRepl browser diff --git a/src/cli/index.coffee b/src/cli/index.coffee deleted file mode 100644 index ec82cc6..0000000 --- a/src/cli/index.coffee +++ /dev/null @@ -1,51 +0,0 @@ -### -Copyright (c) 2014, Groupon, Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -Neither the name of GROUPON nor the names of its contributors may be -used to endorse or promote products derived from this software without -specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -### - -path = require 'path' - -{getConfig} = require 'testium-core' - -USAGE = 'Usage: testium [browser | --update-selenium | --force-update | --help]' -BIN_PATH = path.resolve __dirname, '..', '..', 'bin' - -config = getConfig() - -if config['update-selenium'] || config['download-selenium'] - require('selenium-download').update BIN_PATH, -> - process.exit(0) -else if config['force-update'] - require('selenium-download').forceUpdate BIN_PATH, -> - process.exit(0) -else if config['help'] - console.log USAGE -else - (require './console')() diff --git a/src/testium.coffee b/src/testium.coffee deleted file mode 100644 index 8f98a46..0000000 --- a/src/testium.coffee +++ /dev/null @@ -1,42 +0,0 @@ -### -Copyright (c) 2014, Groupon, Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -Neither the name of GROUPON nor the names of its contributors may be -used to endorse or promote products derived from this software without -specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -### - -{getBrowser, getTestium} = require 'testium-core' - -exports.getBrowser = (options, callback) -> - if typeof options == 'function' - callback = options - options = {} - - getBrowser(options).nodeify callback - -exports.getTestium = getTestium diff --git a/test/cleanup.test.coffee b/test/cleanup.test.coffee deleted file mode 100644 index 9c7f503..0000000 --- a/test/cleanup.test.coffee +++ /dev/null @@ -1,86 +0,0 @@ -{exec, execFile} = require 'child_process' - -assert = require 'assertive' -rimraf = require 'rimraf' -{extend} = require 'lodash' - -LOG_DIRECTORY = "#{__dirname}/cleanup_log" -ENV_OVERRIDES = - testium_logDirectory: LOG_DIRECTORY - -MOCHA_NOISE = - '(node) child_process: options.customFds option is deprecated. Use options.stdio instead.\n' - -getNumProcesses = (done) -> - exec 'ps', (err, stdout, stderr) -> - return done(err) if err? - numProcesses = stdout.split('\n').length - 1 # header line - done null, numProcesses - -testFile = ({file, envOverrides, exitCode, outputMatcher, done}) -> - envOverrides ?= {testium_app: null} - getNumProcesses (err, numProcessesBefore) -> - return done(err) if err? - mocha = execFile './node_modules/.bin/mocha', [ file ], { - env: extend(envOverrides, ENV_OVERRIDES, process.env) - }, (err, stdout, stderr) -> - output = ("#{stdout}\n#{stderr}").replace MOCHA_NOISE, '' - if outputMatcher - assert.match 'output does not match matcher', outputMatcher, output - - try - assert.equal 'mocha exit code', exitCode, mocha.exitCode - - getNumProcesses (err, numProcessesAfter) -> - return done(err) if err? - assert.equal 'number of processes before & after', numProcessesBefore, numProcessesAfter - done() - - catch exitCodeError - console.error output - done exitCodeError - - -describe 'Cleanup test', -> - before "rm -rf #{LOG_DIRECTORY}", (done) -> - rimraf LOG_DIRECTORY, done - - it 'cleans up all child apps after exit without any exceptions', (done) -> - @timeout 10000 - testFile { - file: 'test/cleanup_happy_test.test.coffee' - exitCode: 0 - stderrMatcher: /^$/ - done - } - - it 'cleans up all child apps after uncaught exception', (done) -> - @timeout 10000 - testFile { - file: 'test/cleanup_exception_test.test.coffee' - exitCode: 1 - stderrMatcher: /1 failing/ - done - } - - it 'cleans up all child apps after child dies', (done) -> - @timeout 10000 - testFile { - file: 'test/cleanup_dead_child_test.test.coffee' - envOverrides: - testium_app__command: './node_modules/.bin/coffee test/cleanup_dead_child_app.coffee' - testium_app__port: 1337 - exitCode: 1 - done - } - - it 'cleans up all child apps if child is non-existent', (done) -> - @timeout 10000 - testFile { - file: 'test/cleanup_no_child_test.test.coffee' - envOverrides: - testium_app__command: './node_modules/.bin/coffee test/this_can_be_whatever.coffee' - testium_app__port: 1337 - exitCode: 1 - done - } diff --git a/test/cleanup_dead_child_app.coffee b/test/cleanup_dead_child_app.coffee deleted file mode 100644 index 63dcc2e..0000000 --- a/test/cleanup_dead_child_app.coffee +++ /dev/null @@ -1 +0,0 @@ -throw 'error!' diff --git a/test/cleanup_dead_child_test.test.coffee b/test/cleanup_dead_child_test.test.coffee deleted file mode 100644 index 2985368..0000000 --- a/test/cleanup_dead_child_test.test.coffee +++ /dev/null @@ -1,10 +0,0 @@ -'use strict' - -assert = require 'assertive' -injectBrowser = require '../mocha' - -describe 'Dead child test', -> - before injectBrowser() - - it 'that deliberately hangs because we want the app to die first', (done) -> - setTimeout done, 60000 diff --git a/test/cleanup_exception_test.test.coffee b/test/cleanup_exception_test.test.coffee deleted file mode 100644 index 50608f8..0000000 --- a/test/cleanup_exception_test.test.coffee +++ /dev/null @@ -1,10 +0,0 @@ -'use strict' - -assert = require 'assertive' -injectBrowser = require '../mocha' - -describe 'Failing test', -> - before injectBrowser() - - it 'when running a test', -> - assert.equal 0, 1 diff --git a/test/cleanup_happy_test.test.coffee b/test/cleanup_happy_test.test.coffee deleted file mode 100644 index 441bbab..0000000 --- a/test/cleanup_happy_test.test.coffee +++ /dev/null @@ -1,10 +0,0 @@ -'use strict' - -assert = require 'assertive' -injectBrowser = require '../mocha' - -describe 'Happy test', -> - before injectBrowser() - - it 'that exits without any exceptions', -> - assert.equal 1, 1 diff --git a/test/cleanup_no_child_test.test.coffee b/test/cleanup_no_child_test.test.coffee deleted file mode 100644 index 5b29a0b..0000000 --- a/test/cleanup_no_child_test.test.coffee +++ /dev/null @@ -1,13 +0,0 @@ -'use strict' - -assert = require 'assertive' -injectBrowser = require '../mocha' - -# kill PATH for this subshell so testium can't spawn node, coffee or phantomjs -process.env.PATH = '' - -describe 'No child test', -> - before injectBrowser() - - it 'that deliberately hangs because we want the error to be triggered', (done) -> - setTimeout done, 60000 diff --git a/test/integration/assert/imgLoaded.test.coffee b/test/integration/assert/imgLoaded.test.coffee deleted file mode 100644 index 6a9efbe..0000000 --- a/test/integration/assert/imgLoaded.test.coffee +++ /dev/null @@ -1,37 +0,0 @@ -injectBrowser = require '../../../mocha' -assert = require 'assertive' - -describe 'imgLoaded', -> - before injectBrowser() - - before -> - @browser.navigateTo '/' - - it 'throws an error when the image was not found', -> - msg = 'imgLoaded "img.not-in-the-page": element not found' - err = assert.throws => @browser.assert.imgLoaded 'img.not-in-the-page' - assert.include msg, err.message - - it 'throws an error for non-unique selectors when finding multiple images', -> - msg = 'imgLoaded "img[alt][class]": non-unique selector; count: 3' - err = assert.throws => @browser.assert.imgLoaded 'img[alt][class]' - assert.include msg, err.message - - it 'throws an error for an image not successfully loaded / decoded', -> - msg = 'imgLoaded "img.fail": failed to load ' - err = assert.throws => @browser.assert.imgLoaded 'img.fail' - assert.include msg, err.message - assert.include '/non-existent-image.jpg', err.message - - it 'throws a helpful error for an missing the src attribute', -> - msg = 'imgLoaded "#no": failed to load src-less img#no.src.dude' - err = assert.throws => @browser.assert.imgLoaded '#no' - assert.include msg, err.message - - it 'throws a helpful error when the selector did not match an tag', -> - msg = 'imgLoaded "body": failed to load non-image body' - err = assert.throws => @browser.assert.imgLoaded 'body' - assert.include msg, err.message - - it 'does nothing when the image was successfully loaded and decoded', -> - @browser.assert.imgLoaded 'img.okay' diff --git a/test/integration/console.test.coffee b/test/integration/console.test.coffee deleted file mode 100644 index a881cda..0000000 --- a/test/integration/console.test.coffee +++ /dev/null @@ -1,38 +0,0 @@ -injectBrowser = require '../../mocha' -assert = require 'assertive' - -describe 'console logs', -> - before injectBrowser() - - before -> - @browser.navigateTo '/' - @browser.assert.httpStatus 200 - - # Each browser fails to implement the WebDriver spec - # for console.logs differently. - # Use at your own risk. - it 'can all be retrieved', -> - browser = @browser.capabilities.browserName - - switch browser - when 'firefox' - # firefox ignores this entirely - # CoffeeScript errors on empty when blocks - assert.equal 1, 1 - - when 'chrome' - logs = @browser.getConsoleLogs() - assert.truthy 'console.logs length', logs.length > 0 - - logs = @browser.getConsoleLogs() - assert.equal 0, logs.length - - @browser.click '#log-button' - - logs = @browser.getConsoleLogs() - assert.truthy 'console.logs length', logs.length > 0 - - else - logs = @browser.getConsoleLogs() - assert.truthy 'console.logs length', logs.length > 0 - diff --git a/test/integration/cookie.test.coffee b/test/integration/cookie.test.coffee deleted file mode 100644 index 2b44413..0000000 --- a/test/integration/cookie.test.coffee +++ /dev/null @@ -1,46 +0,0 @@ -injectBrowser = require '../../mocha' -assert = require 'assertive' - -describe 'cookies', -> - before injectBrowser() - - it 'can be set individually', -> - @browser.setCookie - name: 'test_cookie' - value: '3' - - cookie = @browser.getCookie('test_cookie') - assert.equal '3', cookie.value - - it 'can be set in groups', -> - @browser.setCookies [ - { name: 'test_cookie1', value: '5' } - { name: 'test_cookie2', value: '7' } - ] - - cookie1 = @browser.getCookie('test_cookie1') - cookie2 = @browser.getCookie('test_cookie2') - - assert.equal '5', cookie1.value - assert.equal '7', cookie2.value - - it 'can be cleared as a group', -> - @browser.setCookie - name: 'test_cookie' - value: '9' - @browser.clearCookies() - - cookies = @browser.getCookies() - - assert.equal 0, cookies.length - - it 'can be cleared individually', -> - @browser.setCookie - name: 'test_cookie' - value: '4' - - @browser.clearCookie 'test_cookie' - - cookie = @browser.getCookie('test_cookie') - assert.falsey cookie - diff --git a/test/integration/dialog.test.coffee b/test/integration/dialog.test.coffee deleted file mode 100644 index 0b44ca8..0000000 --- a/test/integration/dialog.test.coffee +++ /dev/null @@ -1,70 +0,0 @@ -injectBrowser = require '../../mocha' - -assert = require 'assertive' -{getConfig} = require 'testium-core' - -describe 'dialogs', -> - if getConfig().browser == 'phantomjs' - xit "skipping tests because browser phantomjs doesn't support alerts" - return - - before injectBrowser() - - before -> - @browser.navigateTo '/' - @browser.assert.httpStatus 200 - - @target = @browser.getElement '#alert_target' - @browser.click '.link_to_clear_alert_target' - - xdescribe 'alert', -> - beforeEach -> - @browser.click '.link_to_open_an_alert' - - it "can get an alert text", -> - text = @browser.getAlertText() - @browser.acceptAlert() - assert.equal 'Alert text was not found', 'An alert!', text - - it "can accept an alert", -> - @browser.acceptAlert() - assert.equal 'alerted', @target.get('text') - - it "can dismiss an alert", -> - @browser.dismissAlert() - assert.equal 'alerted', @target.get('text') - - describe 'confirm', -> - beforeEach -> - @browser.click '.link_to_open_a_confirm' - - it "can get confirm text", -> - text = @browser.getAlertText() - @browser.acceptAlert() - assert.equal 'Confirm text was not found', 'A confirmation!', text - - it "can accept a confirm", -> - @browser.acceptAlert() - assert.equal 'confirmed', @target.get('text') - - it "can dismiss a confirm", -> - @browser.dismissAlert() - assert.equal 'dismissed', @target.get('text') - - describe 'prompt', -> - beforeEach -> - @browser.click '.link_to_open_a_prompt' - - it "can get prompt text", -> - text = @browser.getAlertText() - @browser.acceptAlert() - assert.equal 'Confirm text was not found', 'A prompt!', text - - it "can send text to and accept a prompt", -> - @browser.typeAlert 'Some words' - @browser.acceptAlert() - assert.equal 'Some words', @target.get('text') - - it "can dismiss a prompt", -> - @browser.dismissAlert() - assert.equal 'dismissed', @target.get('text') diff --git a/test/integration/element.test.coffee b/test/integration/element.test.coffee deleted file mode 100644 index c6f260f..0000000 --- a/test/integration/element.test.coffee +++ /dev/null @@ -1,237 +0,0 @@ -injectBrowser = require '../../mocha' -assert = require 'assertive' - -stripColors = (message) -> - message.replace /\u001b\[[^m]*m/g, '' - -describe 'element', -> - before injectBrowser() - - before -> - @browser.navigateTo '/' - - it "can get an element's text", -> - element = @browser.getElement 'h1' - text = element.get 'text' - assert.equal 'Element text was not found', 'Test Page!', text - - it "can get special properties from an element", -> - # the "checked" property (when it doesn't exist) - # returns a non-standard response from selenium; - # let's make sure we can handle it properly - element = @browser.getElement '#checkbox' - checked = element.get 'checked' - assert.equal 'checked is null', null, checked - - it "returns null when the element can not be found", -> - element = @browser.getElement '.non-existing' - assert.equal 'Element magically appeared on the page', null, element - - it 'can get several elements', -> - elements = @browser.getElements '.message' - count = elements.length - assert.equal 'Messages were not all found', 3, count - - describe 'elementIsVisible', -> - it 'fails if element does not exist', -> - error = assert.throws => @browser.assert.elementIsVisible '.non-existing' - expectedError = 'Assertion failed: Element not found for selector: .non-existing\nExpected null to be truthy' - assert.equal expectedError, stripColors error.message - - it 'fails if element exists, but is not visible', -> - error = assert.throws => @browser.assert.elementIsVisible '#hidden_thing' - expectedError = 'Assertion failed: Element should be visible for selector: #hidden_thing\nExpected false to be truthy' - assert.equal expectedError, stripColors error.message - - it 'succeeds if element exists and is visible', -> - @browser.assert.elementIsVisible 'h1' - - describe 'elementNotVisible', -> - it 'fails if element does not exist', -> - error = assert.throws => @browser.assert.elementNotVisible '.non-existing' - expectedError = 'Assertion failed: Element not found for selector: .non-existing\nExpected null to be truthy' - assert.equal expectedError, stripColors error.message - - it 'fails if element exists, but is visible', -> - error = assert.throws => @browser.assert.elementNotVisible 'h1' - expectedError = 'Assertion failed: Element should not be visible for selector: h1\nExpected true to be falsey' - assert.equal expectedError, stripColors error.message - - it 'succeeds if element exists and is not visible', -> - @browser.assert.elementNotVisible '#hidden_thing' - - describe 'elementExists', -> - it 'fails if element does not exist', -> - error = assert.throws => @browser.assert.elementExists '.non-existing' - expectedError = 'Assertion failed: Element not found for selector: .non-existing\nExpected null to be truthy' - assert.equal expectedError, stripColors error.message - - it 'succeeds if element exists', -> - @browser.assert.elementExists 'h1' - - describe 'elementDoesntExist', -> - it 'succeeds if element does not exist', -> - @browser.assert.elementDoesntExist '.non-existing' - - it 'fails if element exists', -> - error = assert.throws => @browser.assert.elementDoesntExist 'h1' - expectedError = 'Assertion failed: Element found for selector: h1\nExpected Element to be falsey' - assert.equal expectedError, stripColors error.message - - describe 'elementHasText', -> - it 'finds and returns a single element', -> - element = @browser.assert.elementHasText('.only', 'only one here') - assert.equal "resolve the element's class", 'only', element.get('class') - - it 'finds an element with the wrong text', -> - error = assert.throws => - @browser.assert.elementHasText('.only', 'the wrong text') - - expected = 'Assertion failed: elementHasText: .only\ninclude expected needle to be found in haystack\n- needle: \"the wrong text\"\nhaystack: \"only one here\"' - assert.equal expected, stripColors error.message - - it 'finds no elements', -> - error = assert.throws => - @browser.assert.elementHasText('.does-not-exist', 'some text') - - assert.equal 'Element not found for selector: .does-not-exist', error.message - - it 'finds many elements', -> - error = assert.throws => - @browser.assert.elementHasText '.message', 'some text' - - assert.equal 'assertion needs a unique selector!\n.message has 3 hits in the page', error.message - - it 'succeeds with empty string', -> - @browser.assert.elementHasText '#blank-input', '' - - describe 'elementLacksText', -> - it 'asserts an element lacks some text, and returns the element', -> - element = @browser.assert.elementLacksText '.only', 'this text not present' - assert.equal "resolve the element's class", 'only', element.get('class') - - it 'finds an element incorrectly having some text', -> - error = assert.throws => - @browser.assert.elementLacksText('.only', 'only') - - expected = 'Assertion failed: elementLacksText: .only\nnotInclude expected needle not to be found in haystack\n- needle: \"only\"\n haystack: \"only one here\"' - assert.equal expected, stripColors error.message - - describe 'elementHasValue', -> - it 'finds and returns a single element', -> - element = @browser.assert.elementHasValue('#text-input', 'initialvalue') - assert.equal "resolve the element's id", 'text-input', element.get('id') - - it 'succeeds with empty string', -> - @browser.assert.elementHasValue '#blank-input', '' - - describe 'elementLacksValue', -> - it 'asserts an element lacks some value, and returns the element', -> - element = @browser.assert.elementLacksValue '#text-input', 'this text not present' - assert.equal "resolve the element's id", 'text-input', element.get('id') - - it 'finds an element incorrectly having some text', -> - error = assert.throws => - @browser.assert.elementLacksValue('#text-input', 'initialvalue') - - expected = 'Assertion failed: elementLacksValue: #text-input\nnotInclude expected needle not to be found in haystack\n- needle: \"initialvalue\"\n haystack: \"initialvalue\"' - assert.equal expected, stripColors error.message - - describe 'waitForElementExist', -> - before -> - @browser.navigateTo '/dynamic.html' - - it 'finds an element after waiting', -> - @browser.assert.elementNotVisible('.load_later') - @browser.waitForElementExist('.load_later') - - it 'finds a hidden element', -> - @browser.assert.elementNotVisible('.load_never') - @browser.waitForElementExist('.load_never') - - it 'fails to find an element that never exists', -> - error = assert.throws => - @browser.waitForElementExist('.does-not-exist', 10) - assert.equal 'Timeout (10ms) waiting for element (.does-not-exist) to exist in page.', error.message - - describe 'waitForElementVisible', -> - before -> - @browser.navigateTo '/dynamic.html' - - it 'finds an element after waiting', -> - @browser.assert.elementNotVisible('.load_later') - @browser.waitForElementVisible('.load_later') - - it 'fails to find a visible element within the timeout', -> - error = assert.throws => - @browser.waitForElementVisible('.load_never', 10) - assert.equal 'Timeout (10ms) waiting for element (.load_never) to be visible.', error.message - - it 'fails to find an element that never exists', -> - error = assert.throws => - @browser.waitForElementVisible('.does-not-exist', 10) - assert.equal 'Timeout (10ms) waiting for element (.does-not-exist) to be visible.', error.message - - describe 'waitForElementNotVisible', -> - before -> - @browser.navigateTo '/dynamic.html' - - it 'does not find an existing element after waiting for it to disappear', -> - @browser.assert.elementIsVisible('.hide_later') - @browser.waitForElementNotVisible('.hide_later') - - it 'fails to find a not-visible element within the timeout', -> - error = assert.throws => - @browser.waitForElementNotVisible('.hide_never', 10) - assert.equal 'Timeout (10ms) waiting for element (.hide_never) to not be visible.', error.message - - it 'fails to find an element that never exists', -> - error = assert.throws => - @browser.waitForElementNotVisible('.does-not-exist', 10) - assert.equal 'Timeout (10ms) waiting for element (.does-not-exist) to not be visible.', error.message - - describe '#getElement', -> - before -> - @browser.navigateTo '/' - - beforeEach -> - @element = @browser.getElement 'body' - - it 'fails if selector is undefined', -> - assert.throws -> - @element.getElement(undefined) - - it 'fails if selector is not a String', -> - assert.throws -> - @element.getElement(->) - - it 'succeeds if selector is a String', -> - @element.getElement '.message' - - it 'return null if not found an element on the message element', -> - messageElement = @browser.getElement '.message' - element = messageElement.getElement '.message' - assert.falsey element - - describe '#getElements', -> - before -> - @browser.navigateTo '/' - - beforeEach -> - @element = @browser.getElement 'body' - - it 'fails if selector is undefined', -> - assert.throws -> - @element.getElements(undefined) - - it 'fails if selector is not a String', -> - assert.throws -> - @element.getElements(->) - - it 'succeeds if selector is a String', -> - @element.getElements('.message') - - it 'return empty array if not found an element on the message element', -> - messageElement = @browser.getElement '.message' - elements = messageElement.getElements '.message' - assert.equal 0, elements.length diff --git a/test/integration/evaluate.test.coffee b/test/integration/evaluate.test.coffee deleted file mode 100644 index bf6cdc4..0000000 --- a/test/integration/evaluate.test.coffee +++ /dev/null @@ -1,18 +0,0 @@ -injectBrowser = require '../../mocha' -assert = require 'assertive' - -describe 'evaluate', -> - before injectBrowser() - - before -> - @browser.navigateTo '/' - - it 'runs JavaScript passed as a String', -> - value = @browser.evaluate 'return 3;' - assert.equal 3, value - - it 'runs JavaScript passed as a Function', -> - assert.equal 6, @browser.evaluate -> 6 - - it 'runs JavaScript passed as a Function with optional prepended args', -> - assert.equal 18, @browser.evaluate 3, 6, (a, b) -> a * b diff --git a/test/integration/form.test.coffee b/test/integration/form.test.coffee deleted file mode 100644 index 2454325..0000000 --- a/test/integration/form.test.coffee +++ /dev/null @@ -1,51 +0,0 @@ -injectBrowser = require '../../mocha' -assert = require 'assertive' - -describe 'form', -> - before injectBrowser() - - before -> - @browser.navigateTo '/' - @browser.assert.httpStatus 200 - - it "can get an input's value", -> - element = @browser.getElement '#text-input' - value = element.get 'value' - assert.equal 'Input value was not found', 'initialvalue', value - - it "can clear an input's value", -> - element = @browser.getElement '#text-input' - element.clear() - value = element.get 'value' - assert.equal 'Input value was not cleared', '', value - - it "can type into an input", -> - element = @browser.getElement '#text-input' - element.type 'new stuff' - value = element.get 'value' - assert.equal 'Input value was not typed', 'new stuff', value - - it "can replace the input's value", -> - element = @browser.getElement '#text-input' - value = element.get 'value' - assert.notEqual 'Input value is already empty', '', value - @browser.clearAndType '#text-input', 'new stuff2' - value = element.get 'value' - assert.equal 'Input value was not typed', 'new stuff2', value - - it "can get a textarea's value", -> - element = @browser.getElement '#text-area' - value = element.get 'value' - assert.equal 'Input value was not found', 'initialvalue', value - - it "can clear an textarea's value", -> - element = @browser.getElement '#text-area' - element.clear() - value = element.get 'value' - assert.equal 'Input value was not cleared', '', value - - it "can type into a textarea", -> - element = @browser.getElement '#text-area' - element.type 'new stuff' - value = element.get 'value' - assert.equal 'Input value was not typed', 'new stuff', value diff --git a/test/integration/header.test.coffee b/test/integration/header.test.coffee deleted file mode 100644 index b1dc577..0000000 --- a/test/integration/header.test.coffee +++ /dev/null @@ -1,31 +0,0 @@ -injectBrowser = require '../../mocha' -assert = require 'assertive' - -describe 'headers', -> - before injectBrowser() - - describe 'can be retireved', -> - before -> - @browser.navigateTo '/' - @browser.assert.httpStatus 200 - - it 'as a group', -> - headers = @browser.getHeaders() - contentType = headers['content-type'] - assert.equal "text/html", contentType - - it 'individually', -> - contentType = @browser.getHeader('content-type') - assert.equal "text/html", contentType - - describe 'can be set', -> - before -> - @browser.navigateTo '/echo', - headers: - 'x-something': 'that place' - - it 'to new values', -> - source = @browser.getElement('body').get('text') - body = JSON.parse source - assert.equal body.headers['x-something'], 'that place' - diff --git a/test/integration/navigation.test.coffee b/test/integration/navigation.test.coffee deleted file mode 100644 index d1be61d..0000000 --- a/test/integration/navigation.test.coffee +++ /dev/null @@ -1,98 +0,0 @@ -injectBrowser = require '../../mocha' -assert = require 'assertive' - -describe 'navigation', -> - before injectBrowser() - - it 'directly', -> - @browser.navigateTo '/' - @browser.assert.httpStatus 200 - - it 'with a query arg', -> - @browser.navigateTo '/', query: { 'a b': 'München', x: 0 } - @browser.assert.httpStatus 200 - - @browser.waitForUrl 'http://127.0.0.1:4445/?a%20b=M%C3%BCnchen&x=0', 100 - - it 'with a query string and query arg', -> - @browser.navigateTo '/?x=0', query: { 'a b': 'München' } - @browser.assert.httpStatus 200 - - @browser.waitForUrl 'http://127.0.0.1:4445/?x=0&a%20b=M%C3%BCnchen', 100 - - it 'by clicking a link', -> - @browser.navigateTo '/' - @browser.assert.httpStatus 200 - - @browser.click '.link-to-other-page' - assert.equal '/other-page.html', @browser.getPath() - - it 'by refreshing', -> - @browser.navigateTo '/' - @browser.assert.httpStatus 200 - - @browser.refresh() - @browser.assert.httpStatus 200 - - # No real way to assert this worked - - describe 'waiting for a url', -> - it 'can work with a string', -> - @browser.navigateTo '/redirect-after.html' - @browser.assert.httpStatus 200 - - @browser.waitForUrl 'http://127.0.0.1:4445/index.html' - - it 'can work with a regex', -> - @browser.navigateTo '/redirect-after.html' - @browser.assert.httpStatus 200 - - @browser.waitForUrl /\/index.html/ - - it 'can fail', -> - @browser.navigateTo '/index.html' - @browser.assert.httpStatus 200 - - error = assert.throws => @browser.waitForUrl '/some-random-place.html', 5 - expectedError = 'Timed out (5ms) waiting for url ("/some-random-place.html"). Last value was: "http://127.0.0.1:4445/index.html"' - assert.equal expectedError, error.message - - describe 'groks url and query object', -> - it 'can make its own query regexp', -> - @browser.navigateTo '/redirect-to-query.html' - @browser.waitForUrl '/index.html', - 'a b': 'A B' - c: '1,7' - @browser.assert.httpStatus 200 - - it 'can find query arguments in any order', -> - @browser.navigateTo '/redirect-to-query.html' - @browser.waitForUrl '/index.html', - c: '1,7' - 'a b': 'A B' - - it 'can handle regexp query arguments', -> - @browser.navigateTo '/redirect-to-query.html' - @browser.waitForUrl '/index.html', - c: /[\d,]+/ - 'a b': 'A B' - - it 'detects non-matches too', -> - @browser.navigateTo '/redirect-to-query.html' - - error = assert.throws => @browser.waitForUrl '/index.html', no: 'q', 200 - assert.match /Timed out .* waiting for url/, error.message - - describe 'waiting for a path', -> - it 'can work with a string', -> - @browser.navigateTo '/redirect-after.html' - @browser.assert.httpStatus 200 - - @browser.waitForPath '/index.html' - - it 'can work with a regex', -> - @browser.navigateTo '/redirect-after.html' - @browser.assert.httpStatus 200 - - @browser.waitForPath /index.html/ - diff --git a/test/integration/non_browser.test.coffee b/test/integration/non_browser.test.coffee deleted file mode 100644 index 46d2e9f..0000000 --- a/test/integration/non_browser.test.coffee +++ /dev/null @@ -1,14 +0,0 @@ -http = require 'http' - -injectBrowser = require '../../mocha' -assert = require 'assertive' - -describe 'Non-browser test', -> - before injectBrowser() - - it 'can make a request without using the browser', (done) -> - url = "#{@browser.appUrl}/echo" - http.get(url, (response) -> - assert.equal 200, response.statusCode - done() - ).on 'error', done diff --git a/test/integration/page_data.test.coffee b/test/integration/page_data.test.coffee deleted file mode 100644 index 887a39c..0000000 --- a/test/integration/page_data.test.coffee +++ /dev/null @@ -1,16 +0,0 @@ -injectBrowser = require '../../mocha' -assert = require 'assertive' - -describe 'page data', -> - before injectBrowser() - - before -> - @browser.navigateTo '/' - - it 'title', -> - title = @browser.getPageTitle() - assert.equal 'Test Title', title - - it 'source', -> - source = @browser.getPageSource() - assert.include 'DOCTYPE', source diff --git a/test/integration/proxy.test.coffee b/test/integration/proxy.test.coffee deleted file mode 100644 index 61580bc..0000000 --- a/test/integration/proxy.test.coffee +++ /dev/null @@ -1,42 +0,0 @@ -injectBrowser = require '../../mocha' -assert = require 'assertive' - -describe 'proxy', -> - before injectBrowser() - - describe 'handles errors', -> - it 'with no content type and preserves status code', -> - @browser.navigateTo '/' - @browser.assert.httpStatus 200 - - @browser.navigateTo '/error' - @browser.assert.httpStatus 500 - - it 'that crash and preserves status code', -> - @browser.navigateTo '/crash' - @browser.assert.httpStatus 500 - - it 'handles request abortion', (done) -> - # loads a page that has a resource that will - # be black holed - @browser.navigateTo '/blackholed-resource.html' - @browser.assert.httpStatus 200 - - setTimeout (=> - # when navigating away, the proxy should - # abort the resource request; - # this should not interfere with the new page load - # or status code retrieval - @browser.navigateTo '/' - @browser.assert.httpStatus 200 - done() - - # this can't simply be sync - # because firefox blocks dom-ready - # if we don't wait on the client-side - ), 50 - - it 'handles hashes in urls', -> - @browser.navigateTo '/#deals' - @browser.assert.httpStatus 200 - diff --git a/test/integration/screenshot.test.coffee b/test/integration/screenshot.test.coffee deleted file mode 100644 index 3870813..0000000 --- a/test/integration/screenshot.test.coffee +++ /dev/null @@ -1,18 +0,0 @@ -injectBrowser = require '../../mocha' -assert = require 'assertive' - -getIndexScreenshot = (browser) -> - browser.navigateTo '/' - browser.assert.httpStatus 200 - browser.getScreenshot() - -describe 'screenshots', -> - before injectBrowser() - - describe 'taking', -> - before -> - @indexScreenshot ?= getIndexScreenshot(@browser) - - it 'captures the page', -> - assert.truthy @indexScreenshot.length > 0 - diff --git a/test/integration/ssl.test.coffee b/test/integration/ssl.test.coffee deleted file mode 100644 index f713c77..0000000 --- a/test/integration/ssl.test.coffee +++ /dev/null @@ -1,12 +0,0 @@ -injectBrowser = require '../../mocha' -assert = require 'assertive' - -describe 'ssl/tls', -> - before injectBrowser() - - it 'TLS is supported', -> - @browser.navigateTo 'https://www.howsmyssl.com/a/check' - raw = @browser.getElement('pre').get('text') - sslReport = JSON.parse(raw) - assert.match /^TLS/, sslReport.tls_version - diff --git a/test/integration/unicode.test.coffee b/test/integration/unicode.test.coffee deleted file mode 100644 index 7a0a31f..0000000 --- a/test/integration/unicode.test.coffee +++ /dev/null @@ -1,16 +0,0 @@ -injectBrowser = require '../../mocha' -assert = require 'assertive' - -describe 'unicode support', -> - before injectBrowser() - - before -> - @browser.navigateTo '/' - - it "multibyte unicode can pass through and back from WebDriver", -> - multibyteText = "日本語 text" - element = @browser.getElement '#blank-input' - element.type multibyteText - result = element.get('value') - assert.equal result, multibyteText - diff --git a/test/integration/window.test.coffee b/test/integration/window.test.coffee deleted file mode 100644 index edb7f1c..0000000 --- a/test/integration/window.test.coffee +++ /dev/null @@ -1,39 +0,0 @@ -injectBrowser = require '../../mocha' -assert = require 'assertive' - -describe 'window api', -> - before injectBrowser() - - describe 'frames', -> - before -> - @browser.navigateTo '/windows.html' - @browser.assert.httpStatus 200 - - it 'can be switched', -> - @browser.switchToFrame('cool-frame') - iframeContent = @browser.getElement('.in-iframe-only').get('text') - @browser.switchToDefaultFrame() - primaryContent = @browser.getElement('.in-iframe-only')?.get('text') - assert.equal 'iframe content!', iframeContent - assert.equal undefined, primaryContent - - it 'can be found when nested', -> - @browser.switchToFrame('cool-frame') - @browser.switchToFrame('nested-frame') - element = @browser.getElement('#nested-frame-div') - assert.truthy 'nested frame content', element - - describe 'popups', -> - before -> - @browser.navigateTo '/windows.html' - @browser.assert.httpStatus 200 - - it 'can be opened', -> - @browser.click '#open-popup' - @browser.switchToWindow('popup1') - popupContent = @browser.getElement('.popup-only').get('text') - @browser.closeWindow() - @browser.switchToDefaultWindow() - primaryContent = @browser.getElement('.popup-only')?.get('text') - assert.equal 'popup content!', popupContent - assert.equal undefined, primaryContent diff --git a/test/missing_selenium.test.coffee b/test/missing_selenium.test.coffee deleted file mode 100644 index 7aa7bfb..0000000 --- a/test/missing_selenium.test.coffee +++ /dev/null @@ -1,37 +0,0 @@ -fs = require 'fs' -{execFile} = require 'child_process' - -assert = require 'assertive' -rimraf = require 'rimraf' -{extend} = require 'lodash' - -LOG_DIRECTORY = "#{__dirname}/missing_selenium_log" -TEST_FILE = 'test/integration/cookie.test.coffee' - -ENV_OVERRIDES = { - testium_browser: 'firefox' - testium_selenium__jar: '/tmp/no_such_jar.jar' - testium_logDirectory: LOG_DIRECTORY -} - -describe 'Missing selenium', -> - before "rm -rf #{LOG_DIRECTORY}", (done) -> - rimraf LOG_DIRECTORY, done - - before 'run failing test suite', (done) -> - @timeout 10000 - mocha = execFile './node_modules/.bin/mocha', [ TEST_FILE ], { - env: extend(ENV_OVERRIDES, process.env) - }, (err, @stdout, @stderr) => - try - assert.equal 1, mocha.exitCode - done() - catch exitCodeError - console.log "Error: #{err.stack}" - console.log "stdout: #{@stdout}" - console.log "stderr: #{@stderr}" - done exitCodeError - - it 'mentions useful options', -> - assert.include '$ ./node_modules/.bin/testium --download-selenium', @stdout - assert.include '[selenium]\njar =', @stdout diff --git a/test/mocha.opts b/test/mocha.opts deleted file mode 100644 index 1083fea..0000000 --- a/test/mocha.opts +++ /dev/null @@ -1,2 +0,0 @@ ---compilers test.coffee:coffee-script/register ---recursive diff --git a/test/no_app.test.coffee b/test/no_app.test.coffee deleted file mode 100644 index 2388f50..0000000 --- a/test/no_app.test.coffee +++ /dev/null @@ -1,30 +0,0 @@ -{execFile} = require 'child_process' - -assert = require 'assertive' -rimraf = require 'rimraf' -{extend} = require 'lodash' - -LOG_DIRECTORY = "#{__dirname}/no_app_log" -TEST_FILE = 'test/no_app_test.test.coffee' - -ENV_OVERRIDES = { - testium_app: null -} - -describe 'App not Required', -> - before "rm -rf #{LOG_DIRECTORY}", (done) -> - rimraf LOG_DIRECTORY, done - - it 'run the no_app test', (done) -> - @timeout 10000 - - mocha = execFile './node_modules/.bin/mocha', [ TEST_FILE ], { - env: extend(ENV_OVERRIDES, process.env) - }, (err, @stdout, @stderr) => - try - assert.equal 'mocha exit code', 0, mocha.exitCode - done() - catch exitCodeError - console.error @stderr - done exitCodeError - diff --git a/test/no_app_test.test.coffee b/test/no_app_test.test.coffee deleted file mode 100644 index ff02ed2..0000000 --- a/test/no_app_test.test.coffee +++ /dev/null @@ -1,9 +0,0 @@ -injectBrowser = require '../mocha' -assert = require 'assertive' - -describe 'without an app', -> - before injectBrowser() - - it 'can hit the internet', -> - @browser.navigateTo 'http://google.com' - diff --git a/test/screenshot_integration/force_screenshot.hidden.coffee b/test/screenshot_integration/force_screenshot.hidden.coffee deleted file mode 100644 index 7d1f98b..0000000 --- a/test/screenshot_integration/force_screenshot.hidden.coffee +++ /dev/null @@ -1,23 +0,0 @@ -# The file suffix is .hidden.coffee so mocha does not run this -# by default (it only does this with .test.coffee). - -injectBrowser = require '../../mocha' -assert = require 'assertive' - -describe 'forced screenshot', -> - before injectBrowser() - - it 'my test', -> - @browser.navigateTo '/' - # This is supposed to be failing, the real status code is 200 - assert.equal 'statuscode', 418, @browser.getStatusCode() - - it 'some !%#(*.>:; sPecial chars', -> - @browser.navigateTo '/' - # Supposed to be failing as well, actual text is "only one here" - @browser.assert.elementHasText('.only', 'not on the page') - - it 'does not fail', -> - # empty test should never fail - # This makes sure that when everything is fine we do not take - # screenshots diff --git a/test/screenshots.test.coffee b/test/screenshots.test.coffee deleted file mode 100644 index 9b38933..0000000 --- a/test/screenshots.test.coffee +++ /dev/null @@ -1,45 +0,0 @@ -fs = require 'fs' -{execFile} = require 'child_process' - -assert = require 'assertive' -rimraf = require 'rimraf' -{extend} = require 'lodash' - -LOG_DIRECTORY = "#{__dirname}/screenshot_integration_log" -SCREENSHOT_DIRECTORY = "#{__dirname}/screenshot_integration_log/screenshots" -TEST_FILE = 'test/screenshot_integration/force_screenshot.hidden.coffee' - -ENV_OVERRIDES = { - testium_logDirectory: LOG_DIRECTORY - testium_screenshotDirectory: SCREENSHOT_DIRECTORY -} - -describe 'screenshots', -> - before "rm -rf #{LOG_DIRECTORY}", (done) -> - rimraf LOG_DIRECTORY, done - - before 'run failing test suite', (done) -> - @timeout 10000 - mocha = execFile './node_modules/.bin/mocha', [ TEST_FILE ], { - env: extend(ENV_OVERRIDES, process.env) - }, (err, @stdout, @stderr) => - try - assert.equal 2, mocha.exitCode - done() - catch exitCodeError - console.log "Error: #{err.stack}" - console.log "stdout: #{@stdout}" - console.log "stderr: #{@stderr}" - done exitCodeError - - before "readdir #{SCREENSHOT_DIRECTORY}", -> - @files = fs.readdirSync SCREENSHOT_DIRECTORY - @files.sort() - - it 'creates two screenshots w/ html', -> - assert.deepEqual [ - 'forced_screenshot_my_test.html', - 'forced_screenshot_my_test.png', - 'forced_screenshot_some_sPecial_chars.html', - 'forced_screenshot_some_sPecial_chars.png' - ], @files diff --git a/test/start_timeout.test.coffee b/test/start_timeout.test.coffee deleted file mode 100644 index 2313a71..0000000 --- a/test/start_timeout.test.coffee +++ /dev/null @@ -1,43 +0,0 @@ -{execFile} = require 'child_process' - -assert = require 'assertive' -rimraf = require 'rimraf' -{extend} = require 'lodash' - -LOG_DIRECTORY = "#{__dirname}/start_timeout_log" -TEST_FILE = 'test/integration/cookie.test.coffee' - -ENV_OVERRIDES = { - testium_app__timeout: 250 - testium_logDirectory: LOG_DIRECTORY - never_listen: '1' -} - -describe 'App startup timeout', -> - before "rm -rf #{LOG_DIRECTORY}", (done) -> - rimraf LOG_DIRECTORY, done - - before 'run failing test suite', (done) -> - @timeout 10000 - mocha = execFile './node_modules/.bin/mocha', [ TEST_FILE ], { - env: extend(ENV_OVERRIDES, process.env) - }, (err, @stdout, @stderr) => - try - assert.equal 1, mocha.exitCode - done() - catch exitCodeError - console.log "Error: #{err.stack}" - console.log "stdout: #{@stdout}" - console.log "stderr: #{@stderr}" - done exitCodeError - - it 'mentions helpful details', -> - try - assert.include 'command: testium-example-app', @stdout - assert.include 'timeout: 250ms', @stdout - assert.include 'test/start_timeout_log/application.log', @stdout - assert.include '> Refusing to listen', @stdout - catch error - console.log "stdout: #{@stdout}" - console.log "stderr: #{@stderr}" - throw error