Skip to content

Commit

Permalink
A little cleanup of Selenium IDE Webdriver playback
Browse files Browse the repository at this point in the history
  • Loading branch information
samitbadle committed Feb 27, 2013
1 parent 4fff2dc commit 88f62ce
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ide/main/src/content/remote-selenium-commandhandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ AssertHandler.prototype.execute = function(seleniumApi, command) {
result.terminationCondition = function() {
if (!deferred.isPending()) {
var pResult = deferred.value()[0];
if (result.isRejected()) {
if (deferred.isRejected()) {
throw pResult;
}
if (!pResult.isTrue) {
Expand Down
5 changes: 5 additions & 0 deletions ide/main/src/content/selenium-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ objectExtend(IDETestLoop.prototype, {
commandComplete: function(result) {
this._checkExpectedFailure(result);
if (result.failed) {
//TODO Samit: Remove this workaround and try to connect to selenium server before starting test
if (result.failureMessage.t && result.failureMessage.t === 'RemoteConnectError') {
result.failureMessage = result.failureMessage.m; //unwrap message
setState(Debugger.PAUSED);
}
LOG.error(result.failureMessage);
testCase.debugContext.failed = true;
testCase.debugContext.currentCommand().result = 'failed';
Expand Down
15 changes: 7 additions & 8 deletions ide/main/src/content/webdriver-backed-selenium.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,16 +213,17 @@ WebdriverBackedSelenium.prototype.startNewSession = function() {
// return this.startNewWebdriverSession('firefox').pipe(function() {
return this.startNewWebdriverSession(this.webDriverBrowserString).pipe(function() {
return self.startNewBrowserSession({});
}, function () {
}, function (msg) {
//TODO failed to connect
alert('Failed to start new session');
// alert('Failed to start new session');
return msg;
});
};

WebdriverBackedSelenium.prototype.startNewWebdriverSession = function(browserName) {
var self = this;
return new Deferred(function(deferred) {
LOG.info('Connecting to Selenium Server');
LOG.debug('Connecting to Selenium Server');
httpPost('http://localhost:4444/wd/hub/session',
JSON.stringify({
'desiredCapabilities': {'browserName': browserName}
Expand All @@ -232,8 +233,7 @@ WebdriverBackedSelenium.prototype.startNewWebdriverSession = function(browserNam
self.webdriverSID = self.webdriverResponse.sessionId;
deferred.resolve(self.webdriverSID);
} else {
LOG.error('Could not connect to Selenium Server. Have you started the Selenium Server yet?');
deferred.reject('Could not connect to Selenium Server');
deferred.reject({message: {t: 'RemoteConnectError', m: 'Could not connect to Selenium Server. Have you started the Selenium Server yet?'}});
}
});
});
Expand Down Expand Up @@ -304,7 +304,6 @@ WebdriverBackedSelenium.prototype.webDriverCommand = function(url, opts, args) {
deferred.resolve();
}
} else {
// LOG.error('Could not connect to Selenium Server. Have you started the Selenium Server yet?');
if (response) {
deferred.reject(result.value.message);
} else {
Expand Down Expand Up @@ -340,13 +339,13 @@ function httpPost(url, data, headers, callback) {
callback(httpRequest.responseText, false, httpRequest.status);
} else {
//TODO eliminate alert and signal the failure
alert('There was a problem with the request.\nUrl: ' + url + '\nHttp Status: ' + httpRequest.status + "\nResponse: " + httpRequest.responseText);
// alert('There was a problem with the request.\nUrl: ' + url + '\nHttp Status: ' + httpRequest.status + "\nResponse: " + httpRequest.responseText);
LOG.debug('Error: There was a problem with the request.\nUrl: ' + url + '\nHttp Status: ' + httpRequest.status + "\nResponse: " + httpRequest.responseText);
callback(null, false, httpRequest.status);
}
}
} catch(e) {
//TODO eliminate alert and signal the failure
// alert('Caught Exception in httpPost: ' + e.description);
alert('Caught Exception in httpPost: ' + e);
throw e;
}
Expand Down

0 comments on commit 88f62ce

Please sign in to comment.