protractor
Advanced tools
Comparing version 4.0.7 to 4.0.8
@@ -34,11 +34,6 @@ "use strict"; | ||
} | ||
// Explicitly define webdriver.WebDriver. | ||
// Explicitly define webdriver.WebDriver | ||
// TODO: extend WebDriver from selenium-webdriver typings | ||
var Webdriver = (function () { | ||
function Webdriver() { | ||
this.actions = webdriver.WebDriver.actions; | ||
this.wait = webdriver.WebDriver.wait; | ||
this.sleep = webdriver.WebDriver.sleep; | ||
this.getCurrentUrl = webdriver.WebDriver.getCurrentUrl; | ||
this.getTitle = webdriver.WebDriver.getTitle; | ||
this.takeScreenshot = webdriver.WebDriver.takeScreenshot; | ||
} | ||
@@ -308,3 +303,3 @@ return Webdriver; | ||
'https://github.com/angular/protractor/blob/master/docs/faq.md'; | ||
if (description.startsWith(' - Locator: ')) { | ||
if (description.indexOf(' - Locator: ') == 0) { | ||
errMsg_1 += | ||
@@ -446,56 +441,3 @@ '\nWhile waiting for element with locator' + description; | ||
ProtractorBrowser.prototype.addBaseMockModules_ = function () { | ||
this.addMockModule('protractorBaseModule_', function (trackOutstandingTimeouts) { | ||
var ngMod = angular.module('protractorBaseModule_', []).config([ | ||
'$compileProvider', | ||
function ($compileProvider) { | ||
if ($compileProvider.debugInfoEnabled) { | ||
$compileProvider.debugInfoEnabled(true); | ||
} | ||
} | ||
]); | ||
if (trackOutstandingTimeouts) { | ||
ngMod.config([ | ||
'$provide', | ||
function ($provide) { | ||
$provide.decorator('$timeout', [ | ||
'$delegate', | ||
function ($delegate) { | ||
var $timeout = $delegate; | ||
var taskId = 0; | ||
if (!window['NG_PENDING_TIMEOUTS']) { | ||
window['NG_PENDING_TIMEOUTS'] = {}; | ||
} | ||
var extendedTimeout = function () { | ||
var args = Array.prototype.slice.call(arguments); | ||
if (typeof (args[0]) !== 'function') { | ||
return $timeout.apply(null, args); | ||
} | ||
taskId++; | ||
var fn = args[0]; | ||
window['NG_PENDING_TIMEOUTS'][taskId] = fn.toString(); | ||
var wrappedFn = (function (taskId_) { | ||
return function () { | ||
delete window['NG_PENDING_TIMEOUTS'][taskId_]; | ||
return fn.apply(null, arguments); | ||
}; | ||
})(taskId); | ||
args[0] = wrappedFn; | ||
var promise = $timeout.apply(null, args); | ||
promise.ptorTaskId_ = taskId; | ||
return promise; | ||
}; | ||
extendedTimeout.cancel = function () { | ||
var taskId_ = arguments[0] && arguments[0].ptorTaskId_; | ||
if (taskId_) { | ||
delete window['NG_PENDING_TIMEOUTS'][taskId_]; | ||
} | ||
return $timeout.cancel.apply($timeout, arguments); | ||
}; | ||
return extendedTimeout; | ||
} | ||
]); | ||
} | ||
]); | ||
} | ||
}, this.trackOutstandingTimeouts_); | ||
this.addMockModule('protractorBaseModule_', clientSideScripts.protractorBaseModuleFn, this.trackOutstandingTimeouts_); | ||
}; | ||
@@ -545,10 +487,7 @@ /** | ||
// Ignore the error, and continue trying. This is | ||
// because IE | ||
// driver sometimes (~1%) will throw an unknown error | ||
// from this | ||
// execution. See | ||
// because IE driver sometimes (~1%) will throw an | ||
// unknown error from this execution. See | ||
// https://github.com/angular/protractor/issues/841 | ||
// This shouldn't mask errors because it will fail | ||
// with the timeout | ||
// anyway. | ||
// with the timeout anyway. | ||
return false; | ||
@@ -555,0 +494,0 @@ } |
@@ -723,1 +723,71 @@ /** | ||
'window.clientSideScripts = {%s};', scriptsList.join(', '))); | ||
/** | ||
* Automatically installed by Protractor when a page is loaded, this | ||
* default mock module decorates $timeout to keep track of any | ||
* outstanding timeouts. | ||
* | ||
* @param {boolean} trackOutstandingTimeouts | ||
*/ | ||
exports.protractorBaseModuleFn = function(trackOutstandingTimeouts) { | ||
var ngMod = angular.module('protractorBaseModule_', []).config([ | ||
'$compileProvider', | ||
function($compileProvider) { | ||
if ($compileProvider.debugInfoEnabled) { | ||
$compileProvider.debugInfoEnabled(true); | ||
} | ||
} | ||
]); | ||
if (trackOutstandingTimeouts) { | ||
ngMod.config([ | ||
'$provide', | ||
function ($provide) { | ||
$provide.decorator('$timeout', [ | ||
'$delegate', | ||
function ($delegate) { | ||
var $timeout = $delegate; | ||
var taskId = 0; | ||
if (!window['NG_PENDING_TIMEOUTS']) { | ||
window['NG_PENDING_TIMEOUTS'] = {}; | ||
} | ||
var extendedTimeout= function() { | ||
var args = Array.prototype.slice.call(arguments); | ||
if (typeof(args[0]) !== 'function') { | ||
return $timeout.apply(null, args); | ||
} | ||
taskId++; | ||
var fn = args[0]; | ||
window['NG_PENDING_TIMEOUTS'][taskId] = | ||
fn.toString(); | ||
var wrappedFn = (function(taskId_) { | ||
return function() { | ||
delete window['NG_PENDING_TIMEOUTS'][taskId_]; | ||
return fn.apply(null, arguments); | ||
}; | ||
})(taskId); | ||
args[0] = wrappedFn; | ||
var promise = $timeout.apply(null, args); | ||
promise.ptorTaskId_ = taskId; | ||
return promise; | ||
}; | ||
extendedTimeout.cancel = function() { | ||
var taskId_ = arguments[0] && arguments[0].ptorTaskId_; | ||
if (taskId_) { | ||
delete window['NG_PENDING_TIMEOUTS'][taskId_]; | ||
} | ||
return $timeout.cancel.apply($timeout, arguments); | ||
}; | ||
return extendedTimeout; | ||
} | ||
]); | ||
} | ||
]); | ||
} | ||
}; |
@@ -19,2 +19,3 @@ "use strict"; | ||
// Explicitly define webdriver.WebElement. | ||
// TODO: extend WebElement from selenium-webdriver typings | ||
var WebdriverWebElement = (function () { | ||
@@ -91,4 +92,3 @@ function WebdriverWebElement() { | ||
// TODO(juliemr): might it be easier to combine this with our docs and just | ||
// wrap each | ||
// one explicity with its own documentation? | ||
// wrap each one explicity with its own documentation? | ||
WEB_ELEMENT_FUNCTIONS.forEach(function (fnName) { | ||
@@ -95,0 +95,0 @@ _this[fnName] = function () { |
@@ -19,3 +19,7 @@ // Because this file imports from protractor, you'll need to have it as a | ||
specs: [ 'spec.js' ], | ||
seleniumAddress: 'http://localhost:4444/wd/hub' | ||
seleniumAddress: 'http://localhost:4444/wd/hub', | ||
// You could set no globals to true to avoid jQuery '$' and protractor '$' | ||
// collisions on the global namespace. | ||
noGlobals: true | ||
}; |
106
gulpfile.js
@@ -12,2 +12,3 @@ 'use strict'; | ||
var glob = require('glob'); | ||
var semver = require('semver'); | ||
@@ -39,27 +40,19 @@ var runSpawn = function(done, task, opt_arg, opt_io) { | ||
gulp.task('checkVersion', function(done) { | ||
var version = spawnSync('node', ['--version']).stdout.toString(); | ||
var versionArray = version.replace('v', '').split('.'); | ||
var major = versionArray[0]; | ||
var minor = versionArray[1]; | ||
// read minimum node on package.json | ||
var packageJson = JSON.parse(fs.readFileSync(path.resolve('package.json'))); | ||
var protractorVersion = packageJson.version; | ||
var nodeVersion = packageJson.engines.node.replace('>=',''); | ||
var nodeVersionArray = nodeVersion.split('.'); | ||
var requiredMajor = nodeVersionArray[0]; | ||
var requiredMinor = nodeVersionArray[1]; | ||
var nodeVersion = packageJson.engines.node; | ||
if (major >= requiredMajor && minor >= requiredMinor) { | ||
if (semver.satisfies(process.version, nodeVersion)) { | ||
done(); | ||
} else { | ||
console.error('minimum node version for Protractor ' + protractorVersion + | ||
' is node >= ' + nodeVersion); | ||
return 1; | ||
throw new Error('minimum node version for Protractor ' + protractorVersion + | ||
' is node ' + nodeVersion); | ||
} | ||
}); | ||
gulp.task('built:copy', function() { | ||
return gulp.src(['lib/**/*.js','lib/globals.d.ts']) | ||
gulp.task('built:copy', function(done) { | ||
return gulp.src(['lib/**/*.js','lib/index.d.ts']) | ||
.pipe(gulp.dest('built/')); | ||
done(); | ||
}); | ||
@@ -101,4 +94,4 @@ | ||
gulp.task('prepublish', function(done) { | ||
runSequence('checkVersion', ['jshint', 'format'], 'tsc', 'tsc:globals', 'types', | ||
'ambient', 'built:copy', done); | ||
runSequence('checkVersion', ['jshint', 'format'], 'tsc', 'tsc:globals', | ||
'built:copy', done); | ||
}); | ||
@@ -109,82 +102,5 @@ | ||
['webdriver:update', 'jshint', 'format'], 'tsc', 'tsc:globals', | ||
'types', 'ambient', 'built:copy', done); | ||
'built:copy', done); | ||
}); | ||
gulp.task('default',['prepublish']); | ||
gulp.task('types', function(done) { | ||
var folder = 'built'; | ||
var files = ['browser', 'element', 'locators', 'expectedConditions', | ||
'config', 'plugins', 'ptor']; | ||
var outputFile = path.resolve(folder, 'index.d.ts'); | ||
var contents = ''; | ||
contents += '/// <reference path="../typings/index.d.ts" />\n'; | ||
contents += '/// <reference path="./globals.d.ts" />\n'; | ||
contents += 'import {ActionSequence, By, WebDriver, WebElement, WebElementPromise, promise, promise as wdpromise, until} from \'selenium-webdriver\';\n'; | ||
files.forEach(function(file) { | ||
contents += parseTypingsFile(folder, file); | ||
}); | ||
// remove files with d.ts | ||
glob.sync(folder + '/**/*.d.ts').forEach(function(file) { | ||
fs.unlinkSync(path.resolve(file)); | ||
}); | ||
// write contents to 'built/index.d.ts' | ||
fs.writeFileSync(outputFile, contents); | ||
done(); | ||
}); | ||
var parseTypingsFile = function(folder, file) { | ||
var fileContents = fs.readFileSync(path.resolve(folder, file + '.d.ts')).toString(); | ||
// Remove new lines inside types | ||
fileContents = fileContents.replace( | ||
/webdriver.promise.Promise<\{[a-zA-Z:,; \n]+\}>/g, function(type) { | ||
return type.replace(/\n/g, ''); | ||
} | ||
); | ||
var lines = fileContents.split('\n'); | ||
var contents = ''; | ||
for (var linePos in lines) { | ||
var line = lines[linePos]; | ||
if (!line.startsWith('import')) { | ||
if (line.indexOf('declare') !== -1) { | ||
line = line.replace('declare', '').trim(); | ||
} | ||
// Remove webdriver types, q, http proxy agent | ||
line = removeTypes(line,'webdriver.ActionSequence'); | ||
line = removeTypes(line,'webdriver.promise.Promise<[a-zA-Z{},:; ]+>'); | ||
line = removeTypes(line,'webdriver.util.Condition'); | ||
line = removeTypes(line,'webdriver.WebDriver'); | ||
line = removeTypes(line,'webdriver.Locator'); | ||
line = removeTypes(line,'webdriver.WebElement'); | ||
line = removeTypes(line,'HttpProxyAgent'); | ||
line = removeTypes(line,'Q.Promise<[a-zA-Z{},:; ]+>'); | ||
contents += line + '\n'; | ||
} | ||
} | ||
return contents; | ||
} | ||
var removeTypes = function(line, webdriverType) { | ||
var tempLine = line.trim(); | ||
if (tempLine.startsWith('/**') || tempLine.startsWith('*')) { | ||
return line; | ||
} | ||
return line.replace(new RegExp(webdriverType,'g'), 'any'); | ||
} | ||
gulp.task('ambient', function(done) { | ||
var fileContents = fs.readFileSync(path.resolve('built/index.d.ts')).toString(); | ||
var contents = ''; | ||
contents += 'declare namespace protractor {\n'; | ||
contents += fileContents + '\n'; | ||
contents += '}\n'; | ||
contents += 'declare module "protractor" {\n'; | ||
contents += ' export = protractor; \n'; | ||
contents += '}\n'; | ||
fs.writeFileSync(path.resolve('built/ambient.d.ts'), contents); | ||
done(); | ||
}); |
@@ -17,2 +17,3 @@ { | ||
"@types/node": "^6.0.35", | ||
"@types/q": "^0.0.30", | ||
"adm-zip": "0.4.7", | ||
@@ -36,3 +37,2 @@ "chalk": "^1.1.3", | ||
"@types/optimist": "0.0.28", | ||
"@types/q": "^0.0.30", | ||
"body-parser": "~1.15.2", | ||
@@ -52,2 +52,3 @@ "chai": "~3.5.0", | ||
"run-sequence": "^1.1.5", | ||
"semver": "^5.3.0", | ||
"typescript": "^2.0.0" | ||
@@ -78,3 +79,3 @@ }, | ||
}, | ||
"version": "4.0.7" | ||
"version": "4.0.8" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
99
848786
14
17423
+ Added@types/q@^0.0.30
+ Added@types/q@0.0.30(transitive)