Skip to content

Commit

Permalink
Update notes
Browse files Browse the repository at this point in the history
  • Loading branch information
bootstraponline committed May 20, 2015
1 parent 486831b commit b8c5b49
Show file tree
Hide file tree
Showing 8 changed files with 372 additions and 0 deletions.
12 changes: 12 additions & 0 deletions notes/element_by_id/element_by_id_sync_off.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
browser.get('https://angularjs.org/')
element(by.id('the-basics')).getText()
The Basics

13:06:18.990 INFO - Executing: [execute script: , []])
13:06:18.990 INFO - Executing: [execute script: , []])
13:06:18.990 INFO - Executing: [find elements: By.id: the-basics])
13:06:19.704 INFO - Done: [execute script: , []]
13:06:19.799 INFO - Done: [find elements: By.id: the-basics]
13:06:19.815 INFO - Executing: [get text: 0 [[FirefoxDriver: firefox on MAC (6e728ccc-09cf-0b47-a80e-44bdfdbb8a1b)] -> id: the-basics]])
13:06:19.865 INFO - Done: [execute script: , []]
13:06:19.930 INFO - Done: [get text: 0 [[FirefoxDriver: firefox on MAC (6e728ccc-09cf-0b47-a80e-44bdfdbb8a1b)] -> id: the-basics]]
74 changes: 74 additions & 0 deletions notes/element_by_id/element_by_id_sync_on.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
browser.get('https://angularjs.org/')
element(by.id('the-basics')).getText()
The Basics


the waitForAngular method is called before the get by id method.


13:04:57.684 INFO - Executing: [execute script: , []])
13:04:57.684 INFO - Executing: [execute script: , []])

waitForAngular - clientsidescript

13:04:57.684 INFO - Executing: [execute async script: try { return (function (rootSelector, callback) {
var el = document.querySelector(rootSelector);

try {
if (!window.angular) {
throw new Error('angular could not be found on the window');
}
if (angular.getTestability) {
angular.getTestability(el).whenStable(callback);
} else {
if (!angular.element(el).injector()) {
throw new Error('root element (' + rootSelector + ') has no injector.' +
' this may mean it is not inside ng-app.');
}
angular.element(el).injector().get('$browser').
notifyWhenNoOutstandingRequests(callback);
}
} catch (err) {
callback(err.message);
}
}).apply(this, arguments); }
catch(e) { throw (e instanceof Error) ? e : new Error(e); }, [body]])
13:04:57.684 INFO - Executing: [execute script: , []])
13:04:57.685 INFO - Executing: [execute script: , []])
13:04:58.617 INFO - Done: [execute script: , []]
13:04:58.694 INFO - Done: [execute script: , []]

waitForAngular - clientsidescript

13:04:58.771 INFO - Done: [execute async script: try { return (function (rootSelector, callback) {
var el = document.querySelector(rootSelector);

try {
if (!window.angular) {
throw new Error('angular could not be found on the window');
}
if (angular.getTestability) {
angular.getTestability(el).whenStable(callback);
} else {
if (!angular.element(el).injector()) {
throw new Error('root element (' + rootSelector + ') has no injector.' +
' this may mean it is not inside ng-app.');
}
angular.element(el).injector().get('$browser').
notifyWhenNoOutstandingRequests(callback);
}
} catch (err) {
callback(err.message);
}
}).apply(this, arguments); }
catch(e) { throw (e instanceof Error) ? e : new Error(e); }, [body]]
13:04:58.792 INFO - Executing: [find elements: By.id: the-basics])

13:04:59.019 INFO - Done: [execute script: , []]
13:04:59.085 INFO - Done: [execute script: , []]
13:04:59.218 INFO - Done: [find elements: By.id: the-basics]
13:04:59.240 INFO - Executing: [get text: 0 [[FirefoxDriver: firefox on MAC (6e728ccc-09cf-0b47-a80e-44bdfdbb8a1b)] -> id: the-basics]])
13:04:59.286 INFO - Done: [get text: 0 [[FirefoxDriver: firefox on MAC (6e728ccc-09cf-0b47-a80e-44bdfdbb8a1b)] -> id: the-basics]]



11 changes: 11 additions & 0 deletions notes/get_title/browser_get_title_sync_off.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
browser.get('https://angularjs.org/')
browser.ignoreSynchronization = true
browser.getTitle()

13:14:47.882 INFO - Executing: [get title])
13:14:47.886 INFO - Executing: [execute script: , []])
13:14:47.887 INFO - Executing: [execute script: , []])
13:14:48.330 INFO - Done: [get title]
13:14:51.504 INFO - Done: [execute script: , []]
13:14:51.818 INFO - Done: [execute script: , []]

54 changes: 54 additions & 0 deletions notes/get_title/browser_get_title_sync_on.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
browser.get('https://angularjs.org/')
browser.getTitle()

13:13:21.050 INFO - Executing: [execute script: , []])

wait for angular -- client side script

13:13:21.050 INFO - Executing: [execute async script: try { return (function (rootSelector, callback) {
var el = document.querySelector(rootSelector);

try {
if (!window.angular) {
throw new Error('angular could not be found on the window');
}
if (angular.getTestability) {
angular.getTestability(el).whenStable(callback);
} else {
if (!angular.element(el).injector()) {
throw new Error('root element (' + rootSelector + ') has no injector.' +
' this may mean it is not inside ng-app.');
}
angular.element(el).injector().get('$browser').
notifyWhenNoOutstandingRequests(callback);
}
} catch (err) {
callback(err.message);
}
}).apply(this, arguments); }
catch(e) { throw (e instanceof Error) ? e : new Error(e); }, [body]])
13:13:21.064 INFO - Done: [execute script: , []]
13:13:21.134 INFO - Done: [execute async script: try { return (function (rootSelector, callback) {
var el = document.querySelector(rootSelector);

try {
if (!window.angular) {
throw new Error('angular could not be found on the window');
}
if (angular.getTestability) {
angular.getTestability(el).whenStable(callback);
} else {
if (!angular.element(el).injector()) {
throw new Error('root element (' + rootSelector + ') has no injector.' +
' this may mean it is not inside ng-app.');
}
angular.element(el).injector().get('$browser').
notifyWhenNoOutstandingRequests(callback);
}
} catch (err) {
callback(err.message);
}
}).apply(this, arguments); }
catch(e) { throw (e instanceof Error) ? e : new Error(e); }, [body]]
13:13:21.144 INFO - Executing: [get title])
13:13:21.194 INFO - Done: [get title]
102 changes: 102 additions & 0 deletions notes/protractor_get/protractor_get.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
=begin
var DEFAULT_RESET_URL = 'data:text/html,<html></html>';
if (browserName === 'internet explorer' || browserName === 'safari') {
self.resetUrl = 'about:blank';
}
this.executeScript_(
'window.location.replace("' + destination + '");',
msg('reset url'))
self.executeAsyncScript_(clientSideScripts.testForAngular,
Protractor.prototype.get = function(destination, opt_timeout) {
var timeout = opt_timeout ? opt_timeout : this.getPageTimeout;
var self = this;
destination = this.baseUrl.indexOf('file://') === 0 ?
this.baseUrl + destination : url.resolve(this.baseUrl, destination);
var msg = function(str) {
return 'Protractor.get(' + destination + ') - ' + str;
};
if (this.ignoreSynchronization) {
return this.driver.get(destination);
}
var deferred = webdriver.promise.defer();
this.driver.get(this.resetUrl).then(null, deferred.reject);
this.executeScript_(
'window.name = "' + DEFER_LABEL + '" + window.name;' +
'window.location.replace("' + destination + '");',
msg('reset url'))
.then(null, deferred.reject);
// We need to make sure the new url has loaded before
// we try to execute any asynchronous scripts.
this.driver.wait(function() {
return self.executeScript_('return window.location.href;', msg('get url')).
then(function(url) {
return url !== self.resetUrl;
}, function(err) {
if (err.code == 13) {
// Ignore the error, and continue trying. This is 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.
return false;
} else {
throw err;
}
});
}, timeout,
'waiting for page to load for ' + timeout + 'ms')
.then(null, deferred.reject);
// Make sure the page is an Angular page.
self.executeAsyncScript_(clientSideScripts.testForAngular,
msg('test for angular'),
Math.floor(timeout / 1000)).
then(function(angularTestResult) {
var hasAngular = angularTestResult[0];
if (!hasAngular) {
var message = angularTestResult[1];
throw new Error('Angular could not be found on the page ' +
destination + ' : ' + message);
}
}, function(err) {
throw 'Error while running testForAngular: ' + err.message;
})
.then(null, deferred.reject);
// At this point, Angular will pause for us until angular.resumeBootstrap
// is called.
var moduleNames = [];
for (var i = 0; i < this.mockModules_.length; ++i) {
var mockModule = this.mockModules_[i];
var name = mockModule.name;
moduleNames.push(name);
var executeScriptArgs = [mockModule.script, msg('add mock module ' + name)].
concat(mockModule.args);
this.executeScript_.apply(this, executeScriptArgs).
then(null, function(err) {
throw 'Error while running module script ' + name +
': ' + err.message;
})
.then(null, deferred.reject);
}
this.executeScript_(
'angular.resumeBootstrap(arguments[0]);',
msg('resume bootstrap'),
moduleNames)
.then(deferred.fulfill, deferred.reject);
return deferred;
};
=end
11 changes: 11 additions & 0 deletions notes/protractor_get/protractor_get_website_sync_off.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
browser.ignoreSynchronization = true
browser.get('https://angularjs.org/')

12:45:29.891 INFO - Executing: [execute script: , []])
12:45:29.891 INFO - Executing: [execute script: , []])
12:45:29.891 INFO - Executing: [execute script: , []])
12:45:29.912 INFO - Done: [execute script: , []]
12:45:29.964 INFO - Done: [execute script: , []]
12:45:30.017 INFO - Done: [execute script: , []]
12:45:30.028 INFO - Executing: [get: https://angularjs.org/])
12:45:33.080 INFO - Done: [get: https://angularjs.org/]
86 changes: 86 additions & 0 deletions notes/protractor_get/protractor_get_website_sync_on.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@

12:41:51.320 INFO - Executing: [execute script: , []])
12:41:51.320 INFO - Executing: [get: data:text/html,<html></html>])
12:41:51.320 INFO - Executing: [execute script: , []])
12:41:51.334 INFO - Done: [execute script: , []]
12:41:51.424 INFO - Done: [get: data:text/html,<html></html>]
12:41:51.437 INFO - Executing: [execute script: window.name = "NG_DEFER_BOOTSTRAP!" + window.name;window.location.replace("https://angularjs.org/");, []])
12:41:51.482 INFO - Done: [execute script: , []]
12:41:51.536 INFO - Done: [execute script: window.name = "NG_DEFER_BOOTSTRAP!" + window.name;window.location.replace("https://angularjs.org/");, []]
12:41:51.550 INFO - Executing: [execute script: return window.location.href;, []])
12:41:52.813 INFO - Done: [execute script: return window.location.href;, []]

testForAngular -- looks for resumeBootstrap, part of module mocking in
protractor get.

12:41:52.828 INFO - Executing: [execute async script: try { return (function (attempts, asyncCallback) {
var callback = function(args) {
setTimeout(function() {
asyncCallback(args);
}, 0);
};
var check = function(n) {
try {
if (window.angular && window.angular.resumeBootstrap) {
callback([true, null]);
} else if (n < 1) {
if (window.angular) {
callback([false, 'angular never provided resumeBootstrap']);
} else {
callback([false, 'retries looking for angular exceeded']);
}
} else {
window.setTimeout(function() {check(n - 1);}, 1000);
}
} catch (e) {
callback([false, e]);
}
};
check(attempts);
}).apply(this, arguments); }
catch(e) { throw (e instanceof Error) ? e : new Error(e); }, [10]])
12:41:52.910 INFO - Done: [execute async script: try { return (function (attempts, asyncCallback) {
var callback = function(args) {
setTimeout(function() {
asyncCallback(args);
}, 0);
};
var check = function(n) {
try {
if (window.angular && window.angular.resumeBootstrap) {
callback([true, null]);
} else if (n < 1) {
if (window.angular) {
callback([false, 'angular never provided resumeBootstrap']);
} else {
callback([false, 'retries looking for angular exceeded']);
}
} else {
window.setTimeout(function() {check(n - 1);}, 1000);
}
} catch (e) {
callback([false, e]);
}
};
check(attempts);
}).apply(this, arguments); }
catch(e) { throw (e instanceof Error) ? e : new Error(e); }, [10]]
12:41:52.925 INFO - Executing: [execute script: return (function () {
angular.module('protractorBaseModule_', []).
config(['$compileProvider', function($compileProvider) {
if ($compileProvider.debugInfoEnabled) {
$compileProvider.debugInfoEnabled(true);
}
}]);
}).apply(null, arguments);, []])
12:41:52.980 INFO - Done: [execute script: return (function () {
angular.module('protractorBaseModule_', []).
config(['$compileProvider', function($compileProvider) {
if ($compileProvider.debugInfoEnabled) {
$compileProvider.debugInfoEnabled(true);
}
}]);
}).apply(null, arguments);, []]
12:41:52.991 INFO - Executing: [execute script: angular.resumeBootstrap(arguments[0]);, [[protractorBaseModule_]]])
12:41:54.096 INFO - Done: [execute script: angular.resumeBootstrap(arguments[0]);, [[protractorBaseModule_]]]

22 changes: 22 additions & 0 deletions notes/sync_notes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
sync on find element(s) calls

protractor.js

var methodsToSync = ['getCurrentUrl', 'getPageSource', 'getTitle'];

Protractor.prototype.findElement
Protractor.prototype.findElements

Protractor.prototype.isElementPresent -- does this wait? not sure

Protractor.prototype.get
Protractor.prototype.refresh
Protractor.prototype.navigate

Protractor.prototype.setLocation
Protractor.prototype.getLocationAbsUrl
Protractor.prototype.debugger


redefine core selenium methods to auto sync before execution
to use commands (for example get) on non-angular pages, people can disable synchronization.

0 comments on commit b8c5b49

Please sign in to comment.