Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
chore(selenium) - upgrade to selenium webdriver v 2.52.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cnishina committed Mar 3, 2016
1 parent 1cbbe4f commit 29627f4
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 35 deletions.
4 changes: 2 additions & 2 deletions lib/debugger/debuggerCommons.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ exports.attachDebugger = function(pid, opt_port) {
client.once('ready', function() {
client.setBreakpoint({
type: 'scriptRegExp',
target: '.*executors\.js', //jshint ignore:line
line: 40
target: '.*command\.js', //jshint ignore:line
line: 249
}, function() {
process.send('ready');
client.reqContinue(function() {
Expand Down
9 changes: 4 additions & 5 deletions lib/driverProviders/attachSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var util = require('util'),
q = require('q'),
DriverProvider = require('./driverProvider'),
log = require('../logger'),
webdriver = require('selenium-webdriver'),
WebDriver = require('selenium-webdriver').WebDriver,
executors = require('selenium-webdriver/executors');

var AttachedSessionDriverProvider = function(config) {
Expand All @@ -33,13 +33,12 @@ AttachedSessionDriverProvider.prototype.setupEnv = function() {
* Getting a new driver by attaching an existing session.
*
* @public
* @return {webdriver.WebDriver} webdriver instance
* @return {WebDriver} webdriver instance
*/
AttachedSessionDriverProvider.prototype.getNewDriver = function() {
var executor = executors.createExecutor(this.config_.seleniumAddress);
var newDriver;
newDriver = new webdriver.WebDriver
.attachToSession(executor, this.config_.seleniumSessionId);
var newDriver = WebDriver
.attachToSession(executor, this.config_.seleniumSessionId);
this.drivers_.push(newDriver);
return newDriver;
};
Expand Down
21 changes: 13 additions & 8 deletions lib/driverProviders/driverProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,20 @@ DriverProvider.prototype.quitDriver = function(driver) {
}

var deferred = q.defer();
driver.getSession().then(function(session_) {
if (session_) {
driver.quit().then(function() {
if (driver.getSession() === undefined) {
deferred.resolve();
}
else {
driver.getSession().then(function(session_) {
if (session_) {
driver.quit().then(function() {
deferred.resolve();
});
} else {
deferred.resolve();
});
} else {
deferred.resolve();
}
});
}
});
}
return deferred.promise;
};

Expand Down
13 changes: 5 additions & 8 deletions lib/driverProviders/mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@ var MockExecutor = function() {
};

/**
* @param {!webdriver.Command} command The command to execute.
* @param {function(Error, !bot.response.ResponseObject=)} callback the function
* to invoke when the command response is ready.
* An execute function that returns a promise with a test value.
*/
MockExecutor.prototype.execute = function(command, callback) {
callback(null, {
status: '0',
value: 'test_response'
});
MockExecutor.prototype.execute = function() {
var deferred = q.defer();
deferred.resolve({value: 'test_response'});
return deferred.promise;
};

var MockDriverProvider = function(config) {
Expand Down
5 changes: 2 additions & 3 deletions lib/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ ElementArrayFinder.prototype.count = function() {
return this.getWebElements().then(function(arr) {
return arr.length;
}, function(err) {
if (err.code == webdriver.error.ErrorCode.NO_SUCH_ELEMENT) {
if (err.code == webdriver.error.NoSuchElementError()) {
return 0;
} else {
throw err;
Expand Down Expand Up @@ -671,8 +671,7 @@ var ElementFinder = function(ptor, elementArrayFinder) {
var getWebElements = function() {
return elementArrayFinder.getWebElements().then(function(webElements) {
if (webElements.length === 0) {
throw new webdriver.error.Error(
webdriver.error.ErrorCode.NO_SUCH_ELEMENT,
throw new webdriver.error.NoSuchElementError(
'No element found using locator: ' +
elementArrayFinder.locator_.toString());
} else {
Expand Down
18 changes: 10 additions & 8 deletions lib/protractor.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
var util = require('util');
var url = require('url');
var webdriver = require('selenium-webdriver');
var Command = require('selenium-webdriver/lib/command').Command;
var CommandName = require('selenium-webdriver/lib/command').Name;
var helper = require('./util');
var log = require('./logger');
var ElementArrayFinder = require('./element').ElementArrayFinder;
Expand Down Expand Up @@ -105,16 +107,16 @@ var Protractor = function(webdriverInstance, opt_baseUrl, opt_rootElement,
var methodsToSync = ['getCurrentUrl', 'getPageSource', 'getTitle'];

// Mix all other driver functionality into Protractor.
for (var method in webdriverInstance) {
if (!this[method] && typeof webdriverInstance[method] == 'function') {
var self = this;
Object.getOwnPropertyNames(webdriver.WebDriver.prototype).forEach(function(method) {
if (!self[method] && typeof webdriverInstance[method] == 'function') {
if (methodsToSync.indexOf(method) !== -1) {
mixin(this, webdriverInstance, method, this.waitForAngular.bind(this));
mixin(self, webdriverInstance, method, self.waitForAngular.bind(self));
} else {
mixin(this, webdriverInstance, method);
mixin(self, webdriverInstance, method);
}
}
}
var self = this;
});

/**
* The wrapped webdriver instance. Use this to interact with pages that do
Expand Down Expand Up @@ -304,7 +306,7 @@ Protractor.prototype.executeScript_ = function(script, description) {
}

return this.driver.schedule(
new webdriver.Command(webdriver.CommandName.EXECUTE_SCRIPT).
new Command(CommandName.EXECUTE_SCRIPT).
setParameter('script', script).
setParameter('args', Array.prototype.slice.call(arguments, 2)),
description);
Expand All @@ -328,7 +330,7 @@ Protractor.prototype.executeAsyncScript_ =
script = 'return (' + script + ').apply(null, arguments);';
}
return this.driver.schedule(
new webdriver.Command(webdriver.CommandName.EXECUTE_ASYNC_SCRIPT).
new Command(CommandName.EXECUTE_ASYNC_SCRIPT).
setParameter('script', script).
setParameter('args', Array.prototype.slice.call(arguments, 2)),
description);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"q": "1.4.1",
"request": "~2.67.0",
"saucelabs": "~1.0.1",
"selenium-webdriver": "2.48.2",
"selenium-webdriver": "2.52.0",
"source-map-support": "~0.4.0"
},
"devDependencies": {
Expand Down

0 comments on commit 29627f4

Please sign in to comment.