codeceptjs
Advanced tools
Comparing version 0.3.2 to 0.3.3
@@ -22,3 +22,3 @@ #!/usr/bin/env node | ||
program.command('list [path]') | ||
.alias('sh') | ||
.alias('l') | ||
.description('List all actions for I.') | ||
@@ -25,0 +25,0 @@ .action(require('../lib/command/list')); |
@@ -0,1 +1,7 @@ | ||
## 0.3.3 | ||
**Fixed global installation**. CodeceptJS can now locate globally located modules. | ||
CodeceptJS is also recommended for local installation. | ||
Depending on installation type additional modules (webdriverio, protractor, ...) will be loaded either from local or from global path. | ||
## 0.3.2 | ||
@@ -2,0 +8,0 @@ |
@@ -11,3 +11,3 @@ 'use strict'; | ||
let getTestRoot = require("./utils").getTestRoot; | ||
const npmInstallPackage = require('npm-install-package') | ||
let isLocal = require('../utils').installedLocally(); | ||
@@ -25,2 +25,3 @@ let defaultConfig = { | ||
let helpers = ['WebDriverIO', 'Protractor', 'SeleniumWebdriver','FileSystem']; | ||
let packages; | ||
@@ -39,6 +40,5 @@ let defaultActor = ` | ||
} | ||
`; | ||
`; | ||
module.exports = function (initPath) { | ||
@@ -121,12 +121,3 @@ let testsPath = getTestRoot(initPath); | ||
if (Helper._checkRequirements) { | ||
let packages = Helper._checkRequirements(); | ||
if (packages) { // install package | ||
packages.forEach((packageName) => { | ||
print(`Installing ${packageName}... Please wait`); | ||
npmInstallPackage(packageName, {saveDev: true}, err => { | ||
if (err) return print("Failed installing "+packageName); | ||
print('> Finished installing '+colors.bold(packageName)); | ||
}); | ||
}); | ||
} | ||
packages = Helper._checkRequirements(); | ||
} | ||
@@ -181,6 +172,15 @@ | ||
} | ||
success("Almost done! Create your first test by executing `codeceptjs gt` (generate test) command"); | ||
success("Almost done! Create your first test by executing `codeceptjs gt` (generate test) command"); | ||
if (packages) { | ||
print("\n--"); | ||
if (isLocal) { | ||
print("Please install dependent packages locally: " + colors.bold('npm install --save-dev '+packages.join(' '))); | ||
} else { | ||
print("Please install dependent packages globally: [sudo] " + colors.bold('npm install -g '+packages.join(' '))); | ||
} | ||
} | ||
}); | ||
}); | ||
}; |
@@ -14,6 +14,12 @@ 'use strict'; | ||
let HelperClass = require(module); | ||
if (HelperClass._checkRequirements) { | ||
if (HelperClass._checkRequirements) { | ||
let requirements = HelperClass._checkRequirements(); | ||
if (requirements) { | ||
throw new Error("Required modules are not installed. Please run: npm install "+requirements); | ||
let install; | ||
if (require('./utils').installedLocally()) { | ||
install = "npm install --save-dev "+requirements.join(' '); | ||
} else { | ||
install = "[sudo] npm install -g "+requirements.join(' '); | ||
} | ||
throw new Error("Required modules are not installed.\n\nRUN: "+install); | ||
} | ||
@@ -20,0 +26,0 @@ } |
'use strict'; | ||
let webdriver, protractorWrapper, protractorPlugins, EC; | ||
let protractorWrapper, protractorPlugins, EC; | ||
const requireg = require('requireg') | ||
const SeleniumWebdriver = require('./SeleniumWebdriver'); | ||
@@ -26,6 +27,5 @@ const stringIncludes = require('../assert/include').includes; | ||
* | ||
* | ||
* #### PhantomJS Installation | ||
* | ||
* PhantomJS is a headless alternative to Selenium Server that implements [the WebDriver protocol](https://code.google.com/p/selenium/wiki/JsonWireProtocol). | ||
* PhantomJS is a headless alternative to Selenium Server that implements the WebDriver protocol. | ||
* It allows you to run Selenium tests on a server without a GUI installed. | ||
@@ -44,5 +44,15 @@ * | ||
* * `seleniumAddress` - Selenium address to connect (default: http://localhost:4444/wd/hub) | ||
* * `rootElement` - Root element of AngularJS application (default: body) | ||
* * `capabilities`: {} - list of [Desired Capabilities](https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities) | ||
* * `proxy`: set proxy settings | ||
* | ||
* other options are the same as in [Protractor config](https://github.com/angular/protractor/blob/master/docs/referenceConf.js). | ||
* | ||
* ## Access From Helpers | ||
* | ||
* Receive a WebDriverIO client from a custom helper by accessing `browser` property: | ||
* | ||
* ```js | ||
* this.helpers['Protractor'].browser | ||
* ``` | ||
*/ | ||
@@ -53,7 +63,2 @@ class Protractor extends SeleniumWebdriver { | ||
super(config); | ||
webdriver = require('selenium-webdriver'); | ||
protractorWrapper = require('protractor').wrapDriver; | ||
EC = require('protractor').ExpectedConditions; | ||
this.options = { | ||
@@ -75,5 +80,9 @@ browser: 'firefox', | ||
_init() { | ||
global.by = require('protractor').By; | ||
global.element = require('protractor').element; | ||
this.driverProvider = require('protractor/built/driverProviders/'+this.options.driver)(this.options); | ||
this.webdriver = requireg('protractor/node_modules/selenium-webdriver'); | ||
protractorWrapper = requireg('protractor').wrapDriver; | ||
EC = requireg('protractor').ExpectedConditions; | ||
global.by = requireg('protractor').By; | ||
global.element = requireg('protractor').element; | ||
this.driverProvider = requireg('protractor/built/driverProviders/'+this.options.driver)(this.options); | ||
this.driverProvider.setupEnv(); | ||
@@ -85,6 +94,5 @@ } | ||
try { | ||
require.resolve("protractor"); | ||
require.resolve("selenium-webdriver"); | ||
requireg("protractor"); | ||
} catch(e) { | ||
return ["protractor@^3.0.0"]; | ||
return ["protractor"]; | ||
} | ||
@@ -134,4 +142,12 @@ } | ||
amOnPage(url) { | ||
return super.amOnPage(url); | ||
/** | ||
* Get elements by different locator types, including strict locator | ||
* Should be used in custom helpers: | ||
* | ||
* ```js | ||
* this.helpers['Protractor']._locate({model: 'newTodo'}).then //... | ||
* ``` | ||
*/ | ||
_locate(locator) { | ||
return this.browser.findElements(guessLocator(locator)); | ||
} | ||
@@ -219,4 +235,2 @@ | ||
* Reloads page | ||
* | ||
* *Angular specific* | ||
*/ | ||
@@ -223,0 +237,0 @@ refresh() { |
'use strict'; | ||
let webdriver, until; | ||
let until; | ||
const requireg = require('requireg') | ||
const Helper = require('../helper'); | ||
@@ -45,4 +46,12 @@ const stringIncludes = require('../assert/include').includes; | ||
* * `waitForTimeout`: (optional) sets default wait time in _ms_ for all `wait*` functions. 1000 by default; | ||
* * `capabilities`: {} - list of [Desired Capabilities](https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities) | ||
* | ||
* other options are the same as in [Protractor config](https://github.com/angular/protractor/blob/master/docs/referenceConf.js). | ||
* ## Access From Helpers | ||
* | ||
* Receive a WebDriverIO client from a custom helper by accessing `browser` property: | ||
* | ||
* ```js | ||
* this.helpers['Protractor'].browser | ||
* ``` | ||
* | ||
*/ | ||
@@ -54,5 +63,2 @@ class SeleniumWebdriver extends Helper { | ||
webdriver = require('selenium-webdriver'); | ||
until = require('selenium-webdriver').until; | ||
this.options = { | ||
@@ -67,11 +73,12 @@ browser: 'firefox', | ||
this.options.waitforTimeout /= 1000; // convert to seconds | ||
} | ||
_init() { | ||
global.by = require('selenium-webdriver').By; | ||
this.webdriver = requireg('selenium-webdriver'); | ||
global.by = this.webdriver.By; | ||
this.context = 'body' | ||
this.options.rootElement = 'body' // protractor compat | ||
this.browserBuilder = new webdriver.Builder() | ||
this.browserBuilder = new this.webdriver.Builder() | ||
.withCapabilities(this.options.capabilities) | ||
@@ -87,5 +94,5 @@ .forBrowser(this.options.browser) | ||
try { | ||
require.resolve("selenium-webdriver"); | ||
requireg("selenium-webdriver"); | ||
} catch(e) { | ||
return ["selenium-webdriver@~2.48.2"]; | ||
return ["selenium-webdriver"]; | ||
} | ||
@@ -132,2 +139,14 @@ } | ||
/** | ||
* Get elements by different locator types, including strict locator | ||
* Should be used in custom helpers: | ||
* | ||
* ```js | ||
* this.helpers['SeleniumWebdriver']._locate({name: 'password'}).then //... | ||
* ``` | ||
*/ | ||
_locate(locator) { | ||
return this.browser.findElements(guessLocator(locator)); | ||
} | ||
/** | ||
* {{> ../webapi/amOnPage }} | ||
@@ -226,10 +245,10 @@ */ | ||
if (Array.isArray(key) && ~['Control','Command','Shift','Alt'].indexOf(key[0])) { | ||
modifier = webdriver.Key[key[0].toUpperCase()]; | ||
modifier = this.webdriver.Key[key[0].toUpperCase()]; | ||
key = key[1]; | ||
} | ||
if (key == 'Enter') { | ||
key = webdriver.Key.ENTER; | ||
key = this.webdriver.Key.ENTER; | ||
} | ||
let action = new webdriver.ActionSequence(this.browser); | ||
let action = new this.webdriver.ActionSequence(this.browser); | ||
if (modifier) action.keyDown(modifier) | ||
@@ -578,3 +597,3 @@ action.sendKeys(key); | ||
let el = this.browser.findElement(guessLocator(locator) || by.css(locator)); | ||
return this.browser.wait(until.elementsLocated(el), sec*1000); | ||
return this.browser.wait(this.webdriver.until.elementsLocated(el), sec*1000); | ||
} | ||
@@ -588,3 +607,3 @@ | ||
let el = this.browser.findElement(guessLocator(locator) || by.css(locator)); | ||
return this.browser.wait(until.elementIsVisible(el), sec*1000); | ||
return this.browser.wait(this.webdriver.until.elementIsVisible(el), sec*1000); | ||
} | ||
@@ -601,3 +620,3 @@ | ||
sec = sec || this.options.waitforTimeout; | ||
return this.browser.wait(until.elementTextIs(el, text), sec*1000); | ||
return this.browser.wait(this.webdriver.until.elementTextIs(el, text), sec*1000); | ||
} | ||
@@ -604,0 +623,0 @@ |
@@ -13,2 +13,3 @@ 'use strict'; | ||
const path = require('path'); | ||
const requireg = require('requireg'); | ||
@@ -29,3 +30,3 @@ let withinStore = {}; | ||
* | ||
* PhantomJS is a headless alternative to Selenium Server that implements [the WebDriver protocol](https://code.google.com/p/selenium/wiki/JsonWireProtocol). | ||
* PhantomJS is a headless alternative to Selenium Server that implements the WebDriver protocol. | ||
* It allows you to run Selenium tests on a server without a GUI installed. | ||
@@ -44,2 +45,3 @@ * | ||
* * `waitForTimeout`: (optional) sets default wait time in *ms* for all `wait*` functions. 1000 by default; | ||
* * `desiredCapabilities`: | ||
* | ||
@@ -96,5 +98,6 @@ * | ||
* | ||
* Please refer to [Selenium - Proxy Object](https://code.google.com/p/selenium/wiki/DesiredCapabilities#Proxy_JSON_Object) for more information. | ||
* Please refer to [Selenium - Proxy Object](https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities) for more information. | ||
* | ||
* ## Cloud Providers | ||
* ### Cloud Providers | ||
* | ||
* WebDriverIO makes it possible to execute tests against services like `Sauce Labs` `BrowserStack` `TestingBot` | ||
@@ -128,3 +131,4 @@ * Check out their documentation on [available parameters](http://webdriver.io/guide/testrunner/cloudservices.html) | ||
* | ||
* ## Multiremote Capabilities | ||
* ### Multiremote Capabilities | ||
* | ||
* This is a work in progress but you can control two browsers at a time right out of the box. | ||
@@ -169,3 +173,3 @@ * Individual control is something that is planned for a later version. | ||
super(config); | ||
webdriverio = require('webdriverio'); | ||
webdriverio = requireg('webdriverio'); | ||
@@ -205,5 +209,5 @@ // set defaults | ||
try { | ||
require.resolve("webdriverio"); | ||
requireg("webdriverio"); | ||
} catch(e) { | ||
return ["webdriverio@^4.0.4"]; | ||
return ["webdriverio"]; | ||
} | ||
@@ -210,0 +214,0 @@ } |
var fs = require('fs'); | ||
var path = require('path'); | ||
@@ -18,4 +19,8 @@ module.exports.fileExists = function (filePath) { | ||
module.exports.installedLocally = function() { | ||
return path.resolve(__dirname+'/../').indexOf(process.cwd()) === 0; | ||
} | ||
module.exports.methodsOfObject = function (obj, className) { | ||
var methods = []; | ||
var methods = []; | ||
@@ -79,4 +84,4 @@ const standard = [ | ||
module.exports.test = { | ||
submittedData: function (dataFile) { | ||
submittedData: function (dataFile) { | ||
return function (key) { | ||
@@ -88,3 +93,3 @@ var data = JSON.parse(fs.readFileSync(dataFile, 'utf8')); | ||
return data; | ||
} | ||
} | ||
}, | ||
@@ -91,0 +96,0 @@ |
{ | ||
"name": "codeceptjs", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"description": "Modern Era Aceptance Testing Framework for NodeJS", | ||
@@ -28,2 +28,3 @@ "homepage": "http://codecept.io", | ||
"dependencies": { | ||
"co": "^4.6.0", | ||
"colors": "^1.1.2", | ||
@@ -35,4 +36,3 @@ "commander": "^2.9.0", | ||
"mocha": "^2.4.2", | ||
"npm-install-package": "^1.0.2", | ||
"co": "^4.6.0" | ||
"requireg": "^0.1.5" | ||
}, | ||
@@ -57,4 +57,4 @@ "devDependencies": { | ||
"guppy-pre-commit": "^0.3.0", | ||
"protractor": "^3.0.0", | ||
"selenium-webdriver": "~2.48.2", | ||
"protractor": "^3.2.2", | ||
"selenium-webdriver": "^2.53.1", | ||
"sinon": "^1.17.2", | ||
@@ -61,0 +61,0 @@ "webdriverio": ">3.4.0 <5.0.0" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
143350
4184
16
+ Addedrequireg@^0.1.5
+ Addeddeep-extend@0.6.0(transitive)
+ Addedini@1.3.8(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addednested-error-stacks@2.0.1(transitive)
+ Addedpath-parse@1.0.7(transitive)
+ Addedrc@1.2.8(transitive)
+ Addedrequireg@0.1.8(transitive)
+ Addedresolve@1.7.1(transitive)
+ Addedstrip-json-comments@2.0.1(transitive)
- Removednpm-install-package@^1.0.2
- Removednoop2@2.0.0(transitive)
- Removednpm-install-package@1.1.0(transitive)