Skip to content

Commit

Permalink
Add repeater notes
Browse files Browse the repository at this point in the history
  • Loading branch information
bootstraponline committed Jun 3, 2015
1 parent 2fa09a0 commit 428aab9
Show file tree
Hide file tree
Showing 9 changed files with 1,622 additions and 0 deletions.
94 changes: 94 additions & 0 deletions notes/element_chaining_debug.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
debugging 'should allow chaining while returning a single column'

["allinfo in days", false, 2, "name", "{ebfdf19b-a4a8-be46-8118-6f313da550fd}", nil]



The element reference isn't being sent properly.


Ruby server output:

catch(e) { throw (e instanceof Error) ? e : new Error(e); }, [allinfo in days, false, 2, name, 0, body]])


element.ref is 0


Protractor server output:

[allinfo in days, false, 2, name, [[FirefoxDriver: firefox on MAC (7f28005d-8e97-024e-86aa-879ee42d9e76)] -> css selector: .allinfo], body]]

catch(e) { throw (e instanceof Error) ? e : new Error(e); }, [allinfo in days, false, 2, name, [[FirefoxDriver: firefox on MAC (7f28005d-8e97-024e-86aa-879ee42d9e76)] -> css selector: .allinfo], body]]

---

browser.get('http://localhost:8081/#/repeater')


var secondName = element(by.css('.allinfo')).element(by.repeater('allinfo in days').column('name').row(2))

---

> e.ref
=> "2"


driver.execute_script 'return arguments[0].tagName', e
> DIV
driver.execute_script 'return arguments[0].tagName', e.ref
> nil

driver.execute_script 'return arguments[0].tagName', 2
=> nil

driver.execute_script 'return arguments[0].tagName', '2'
=> nil


driver.execute_script 'return arguments[0].tagName', '{7c79f087-b7a2-dd43-be77-2a4076cb5959}'
=> nil


e = browser.element(tag_name: 'div')


---

> command_hash
=> {:script=>"return arguments[0].tagName", :args=>[#<Selenium::WebDriver::Element:0x..fea95b8c7217851b0 id="0">]}

---

e = browser.element(tag_name: 'div')
driver.execute_script 'return arguments[0].tagName', e

Requesting: {"script":"return arguments[0].tagName","args":["#<Watir::HTMLElement:0x007f8a6d098ae0>"]}

patched webdriver http default to output request body

def new_request_for(verb, url, headers, payload)
puts "Requesting: #{req.body}"

---

e = driver.find_element(tag_name: 'div')
driver.execute_script 'return arguments[0].tagName', e
Requesting: {"script":"return arguments[0].tagName","args":[{"ELEMENT":"0"}]}

----

> puts e.to_json
{"ELEMENT":"0"}

---


element id changes depending on if a remote bridge or a firefox bridge is used.
remote bridges start at 0 and go up by one.

firefox bridge uses hashes.

---

driver.execute_script 'return arguments[0].tagName', WrappedParent.new('0')
150 changes: 150 additions & 0 deletions notes/repeater/findAllRepeaterRows_annotated.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
browser.get('http://localhost:8081/#/repeater')
var partialMatch = element(by.repeater('baz in days'));
partialMatch.getText()


16:09:01.247 INFO - Executing: [execute script: , []])
16:09:01.247 INFO - Executing: [execute script: , []])
16:09:01.248 INFO - Executing: [execute script: , []])
// wait for angular
16:09:01.247 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]])
16:09:01.274 INFO - Done: [execute script: , []]
16:09:01.338 INFO - Done: [execute script: , []]
16:09:01.392 INFO - Done: [execute script: , []]
16:09:01.450 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]]

// -- function (repeater, exact, using)
// [baz in days, false, null, body]
// findAllRepeaterRows -- client side script
16:09:01.467 INFO - Executing: [execute script: try { return (function (repeater, exact, using) {
function repeaterMatch(ngRepeat, repeater, exact) {
if (exact) {
return ngRepeat.split(' track by ')[0].split(' as ')[0].split('|')[0].
trim() == repeater;
} else {
return ngRepeat.indexOf(repeater) != -1;
}
}

using = using || document;

var rows = [];
var prefixes = ['ng-', 'ng_', 'data-ng-', 'x-ng-', 'ng\\:'];
for (var p = 0; p < prefixes.length; ++p) {
var attr = prefixes[p] + 'repeat';
var repeatElems = using.querySelectorAll('[' + attr + ']');
attr = attr.replace(/\\/g, '');
for (var i = 0; i < repeatElems.length; ++i) {
if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {
rows.push(repeatElems[i]);
}
}
}
for (var p = 0; p < prefixes.length; ++p) {
var attr = prefixes[p] + 'repeat-start';
var repeatElems = using.querySelectorAll('[' + attr + ']');
attr = attr.replace(/\\/g, '');
for (var i = 0; i < repeatElems.length; ++i) {
if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {
var elem = repeatElems[i];
while (elem.nodeType != 8 ||
!repeaterMatch(elem.nodeValue, repeater, exact)) {
if (elem.nodeType == 1) {
rows.push(elem);
}
elem = elem.nextSibling;
}
}
}
}
return rows;
}).apply(this, arguments); }
catch(e) { throw (e instanceof Error) ? e : new Error(e); }, [baz in days, false, null, body]])
16:09:01.554 INFO - Done: [execute script: try { return (function (repeater, exact, using) {
function repeaterMatch(ngRepeat, repeater, exact) {
if (exact) {
return ngRepeat.split(' track by ')[0].split(' as ')[0].split('|')[0].
trim() == repeater;
} else {
return ngRepeat.indexOf(repeater) != -1;
}
}

using = using || document;

var rows = [];
var prefixes = ['ng-', 'ng_', 'data-ng-', 'x-ng-', 'ng\\:'];
for (var p = 0; p < prefixes.length; ++p) {
var attr = prefixes[p] + 'repeat';
var repeatElems = using.querySelectorAll('[' + attr + ']');
attr = attr.replace(/\\/g, '');
for (var i = 0; i < repeatElems.length; ++i) {
if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {
rows.push(repeatElems[i]);
}
}
}
for (var p = 0; p < prefixes.length; ++p) {
var attr = prefixes[p] + 'repeat-start';
var repeatElems = using.querySelectorAll('[' + attr + ']');
attr = attr.replace(/\\/g, '');
for (var i = 0; i < repeatElems.length; ++i) {
if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {
var elem = repeatElems[i];
while (elem.nodeType != 8 ||
!repeaterMatch(elem.nodeValue, repeater, exact)) {
if (elem.nodeType == 1) {
rows.push(elem);
}
elem = elem.nextSibling;
}
}
}
}
return rows;
}).apply(this, arguments); }
catch(e) { throw (e instanceof Error) ? e : new Error(e); }, [baz in days, false, null, body]]
16:09:01.570 INFO - Executing: [get text: 0 [org.openqa.selenium.remote.RemoteWebElement@a7eb949e -> unknown locator]])
16:09:01.623 INFO - Done: [get text: 0 [org.openqa.selenium.remote.RemoteWebElement@a7eb949e -> unknown locator]]
145 changes: 145 additions & 0 deletions notes/repeater/findAllRepeaterRows_raw.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
browser.get('http://localhost:8081/#/repeater')
var partialMatch = element(by.repeater('baz in days'));
partialMatch.getText()


16:09:01.247 INFO - Executing: [execute script: , []])
16:09:01.247 INFO - Executing: [execute script: , []])
16:09:01.248 INFO - Executing: [execute script: , []])
16:09:01.247 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]])
16:09:01.274 INFO - Done: [execute script: , []]
16:09:01.338 INFO - Done: [execute script: , []]
16:09:01.392 INFO - Done: [execute script: , []]
16:09:01.450 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]]
16:09:01.467 INFO - Executing: [execute script: try { return (function (repeater, exact, using) {
function repeaterMatch(ngRepeat, repeater, exact) {
if (exact) {
return ngRepeat.split(' track by ')[0].split(' as ')[0].split('|')[0].
trim() == repeater;
} else {
return ngRepeat.indexOf(repeater) != -1;
}
}

using = using || document;

var rows = [];
var prefixes = ['ng-', 'ng_', 'data-ng-', 'x-ng-', 'ng\\:'];
for (var p = 0; p < prefixes.length; ++p) {
var attr = prefixes[p] + 'repeat';
var repeatElems = using.querySelectorAll('[' + attr + ']');
attr = attr.replace(/\\/g, '');
for (var i = 0; i < repeatElems.length; ++i) {
if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {
rows.push(repeatElems[i]);
}
}
}
for (var p = 0; p < prefixes.length; ++p) {
var attr = prefixes[p] + 'repeat-start';
var repeatElems = using.querySelectorAll('[' + attr + ']');
attr = attr.replace(/\\/g, '');
for (var i = 0; i < repeatElems.length; ++i) {
if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {
var elem = repeatElems[i];
while (elem.nodeType != 8 ||
!repeaterMatch(elem.nodeValue, repeater, exact)) {
if (elem.nodeType == 1) {
rows.push(elem);
}
elem = elem.nextSibling;
}
}
}
}
return rows;
}).apply(this, arguments); }
catch(e) { throw (e instanceof Error) ? e : new Error(e); }, [baz in days, false, null, body]])
16:09:01.554 INFO - Done: [execute script: try { return (function (repeater, exact, using) {
function repeaterMatch(ngRepeat, repeater, exact) {
if (exact) {
return ngRepeat.split(' track by ')[0].split(' as ')[0].split('|')[0].
trim() == repeater;
} else {
return ngRepeat.indexOf(repeater) != -1;
}
}

using = using || document;

var rows = [];
var prefixes = ['ng-', 'ng_', 'data-ng-', 'x-ng-', 'ng\\:'];
for (var p = 0; p < prefixes.length; ++p) {
var attr = prefixes[p] + 'repeat';
var repeatElems = using.querySelectorAll('[' + attr + ']');
attr = attr.replace(/\\/g, '');
for (var i = 0; i < repeatElems.length; ++i) {
if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {
rows.push(repeatElems[i]);
}
}
}
for (var p = 0; p < prefixes.length; ++p) {
var attr = prefixes[p] + 'repeat-start';
var repeatElems = using.querySelectorAll('[' + attr + ']');
attr = attr.replace(/\\/g, '');
for (var i = 0; i < repeatElems.length; ++i) {
if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {
var elem = repeatElems[i];
while (elem.nodeType != 8 ||
!repeaterMatch(elem.nodeValue, repeater, exact)) {
if (elem.nodeType == 1) {
rows.push(elem);
}
elem = elem.nextSibling;
}
}
}
}
return rows;
}).apply(this, arguments); }
catch(e) { throw (e instanceof Error) ? e : new Error(e); }, [baz in days, false, null, body]]
16:09:01.570 INFO - Executing: [get text: 0 [org.openqa.selenium.remote.RemoteWebElement@a7eb949e -> unknown locator]])
16:09:01.623 INFO - Done: [get text: 0 [org.openqa.selenium.remote.RemoteWebElement@a7eb949e -> unknown locator]]
Loading

0 comments on commit 428aab9

Please sign in to comment.