How to use repeaterMatch method in Protractor

Best JavaScript code snippet using protractor

clientsidescripts.js

Source:clientsidescripts.js Github

copy

Full Screen

...101 }102 }103 return matches; /* Return the whole array for webdriver.findElements. */104};105function repeaterMatch(ngRepeat, repeater, exact) {106 if (exact) {107 return ngRepeat.split(' track by ')[0].split(' as ')[0].split('|')[0].108 split('=')[0].trim() == repeater;109 } else {110 return ngRepeat.indexOf(repeater) != -1;111 }112}113/**114 * Find an array of elements matching a row within an ng-repeat.115 * Always returns an array of only one element for plain old ng-repeat.116 * Returns an array of all the elements in one segment for ng-repeat-start.117 *118 * @param {string} repeater The text of the repeater, e.g. 'cat in cats'.119 * @param {boolean} exact Whether the repeater needs to be matched exactly120 * @param {number} index The row index.121 * @param {Element} using The scope of the search.122 *123 * @return {Array.<Element>} The row of the repeater, or an array of elements124 * in the first row in the case of ng-repeat-start.125 */126function findRepeaterRows(repeater, exact, index, using) {127 using = using || document;128 var prefixes = ['ng-', 'ng_', 'data-ng-', 'x-ng-', 'ng\\:'];129 var rows = [];130 for (var p = 0; p < prefixes.length; ++p) {131 var attr = prefixes[p] + 'repeat';132 var repeatElems = using.querySelectorAll('[' + attr + ']');133 attr = attr.replace(/\\/g, '');134 for (var i = 0; i < repeatElems.length; ++i) {135 if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {136 rows.push(repeatElems[i]);137 }138 }139 }140 /* multiRows is an array of arrays, where each inner array contains141 one row of elements. */142 var multiRows = [];143 for (var p = 0; p < prefixes.length; ++p) {144 var attr = prefixes[p] + 'repeat-start';145 var repeatElems = using.querySelectorAll('[' + attr + ']');146 attr = attr.replace(/\\/g, '');147 for (var i = 0; i < repeatElems.length; ++i) {148 if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {149 var elem = repeatElems[i];150 var row = [];151 while (elem.nodeType != 8 ||152 !repeaterMatch(elem.nodeValue, repeater, exact)) {153 if (elem.nodeType == 1) {154 row.push(elem);155 }156 elem = elem.nextSibling;157 }158 multiRows.push(row);159 }160 }161 }162 var row = rows[index] || [], multiRow = multiRows[index] || [];163 return [].concat(row, multiRow);164};165functions.findRepeaterRows = wrapWithHelpers(findRepeaterRows, repeaterMatch); 166 /**167 * Find all rows of an ng-repeat.168 *169 * @param {string} repeater The text of the repeater, e.g. 'cat in cats'.170 * @param {boolean} exact Whether the repeater needs to be matched exactly171 * @param {Element} using The scope of the search.172 *173 * @return {Array.<Element>} All rows of the repeater.174 */175function findAllRepeaterRows(repeater, exact, using) {176 using = using || document;177 var rows = [];178 var prefixes = ['ng-', 'ng_', 'data-ng-', 'x-ng-', 'ng\\:'];179 for (var p = 0; p < prefixes.length; ++p) {180 var attr = prefixes[p] + 'repeat';181 var repeatElems = using.querySelectorAll('[' + attr + ']');182 attr = attr.replace(/\\/g, '');183 for (var i = 0; i < repeatElems.length; ++i) {184 if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {185 rows.push(repeatElems[i]);186 }187 }188 }189 for (var p = 0; p < prefixes.length; ++p) {190 var attr = prefixes[p] + 'repeat-start';191 var repeatElems = using.querySelectorAll('[' + attr + ']');192 attr = attr.replace(/\\/g, '');193 for (var i = 0; i < repeatElems.length; ++i) {194 if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {195 var elem = repeatElems[i];196 while (elem.nodeType != 8 ||197 !repeaterMatch(elem.nodeValue, repeater, exact)) {198 if (elem.nodeType == 1) {199 rows.push(elem);200 }201 elem = elem.nextSibling;202 }203 }204 }205 }206 return rows;207};208functions.findAllRepeaterRows = wrapWithHelpers(findAllRepeaterRows, repeaterMatch);209/**210 * Find an element within an ng-repeat by its row and column.211 *212 * @param {string} repeater The text of the repeater, e.g. 'cat in cats'.213 * @param {boolean} exact Whether the repeater needs to be matched exactly214 * @param {number} index The row index.215 * @param {string} binding The column binding, e.g. '{{cat.name}}'.216 * @param {Element} using The scope of the search.217 * @param {string} rootSelector The selector to use for the root app element.218 *219 * @return {Array.<Element>} The element in an array.220 */221function findRepeaterElement(repeater, exact, index, binding, using, rootSelector) {222 var matches = [];223 var root = document.querySelector(rootSelector || 'body');224 using = using || document;225 var rows = [];226 var prefixes = ['ng-', 'ng_', 'data-ng-', 'x-ng-', 'ng\\:'];227 for (var p = 0; p < prefixes.length; ++p) {228 var attr = prefixes[p] + 'repeat';229 var repeatElems = using.querySelectorAll('[' + attr + ']');230 attr = attr.replace(/\\/g, '');231 for (var i = 0; i < repeatElems.length; ++i) {232 if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {233 rows.push(repeatElems[i]);234 }235 }236 }237 /* multiRows is an array of arrays, where each inner array contains238 one row of elements. */239 var multiRows = [];240 for (var p = 0; p < prefixes.length; ++p) {241 var attr = prefixes[p] + 'repeat-start';242 var repeatElems = using.querySelectorAll('[' + attr + ']');243 attr = attr.replace(/\\/g, '');244 for (var i = 0; i < repeatElems.length; ++i) {245 if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {246 var elem = repeatElems[i];247 var row = [];248 while (elem.nodeType != 8 || (elem.nodeValue &&249 !repeaterMatch(elem.nodeValue, repeater, exact))) {250 if (elem.nodeType == 1) {251 row.push(elem);252 }253 elem = elem.nextSibling;254 }255 multiRows.push(row);256 }257 }258 }259 var row = rows[index];260 var multiRow = multiRows[index];261 var bindings = [];262 if (row) {263 if (angular.getTestability) {264 matches.push.apply(265 matches,266 angular.getTestability(root).findBindings(row, binding));267 } else {268 if (row.className.indexOf('ng-binding') != -1) {269 bindings.push(row);270 }271 var childBindings = row.getElementsByClassName('ng-binding');272 for (var i = 0; i < childBindings.length; ++i) {273 bindings.push(childBindings[i]);274 }275 }276 }277 if (multiRow) {278 for (var i = 0; i < multiRow.length; ++i) {279 var rowElem = multiRow[i];280 if (angular.getTestability) {281 matches.push.apply(282 matches,283 angular.getTestability(root).findBindings(rowElem, binding));284 } else {285 if (rowElem.className.indexOf('ng-binding') != -1) {286 bindings.push(rowElem);287 }288 var childBindings = rowElem.getElementsByClassName('ng-binding');289 for (var j = 0; j < childBindings.length; ++j) {290 bindings.push(childBindings[j]);291 }292 }293 }294 }295 for (var i = 0; i < bindings.length; ++i) {296 var dataBinding = angular.element(bindings[i]).data('$binding');297 if (dataBinding) {298 var bindingName = dataBinding.exp || dataBinding[0].exp || dataBinding;299 if (bindingName.indexOf(binding) != -1) {300 matches.push(bindings[i]);301 }302 }303 }304 return matches;305};306functions.findRepeaterElement = wrapWithHelpers(findRepeaterElement, repeaterMatch);307/**308 * Find the elements in a column of an ng-repeat.309 *310 * @param {string} repeater The text of the repeater, e.g. 'cat in cats'.311 * @param {boolean} exact Whether the repeater needs to be matched exactly312 * @param {string} binding The column binding, e.g. '{{cat.name}}'.313 * @param {Element} using The scope of the search.314 * @param {string} rootSelector The selector to use for the root app element.315 *316 * @return {Array.<Element>} The elements in the column.317 */318function findRepeaterColumn(repeater, exact, binding, using, rootSelector) {319 var matches = [];320 var root = document.querySelector(rootSelector || 'body');321 using = using || document;322 var rows = [];323 var prefixes = ['ng-', 'ng_', 'data-ng-', 'x-ng-', 'ng\\:'];324 for (var p = 0; p < prefixes.length; ++p) {325 var attr = prefixes[p] + 'repeat';326 var repeatElems = using.querySelectorAll('[' + attr + ']');327 attr = attr.replace(/\\/g, '');328 for (var i = 0; i < repeatElems.length; ++i) {329 if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {330 rows.push(repeatElems[i]);331 }332 }333 }334 /* multiRows is an array of arrays, where each inner array contains335 one row of elements. */336 var multiRows = [];337 for (var p = 0; p < prefixes.length; ++p) {338 var attr = prefixes[p] + 'repeat-start';339 var repeatElems = using.querySelectorAll('[' + attr + ']');340 attr = attr.replace(/\\/g, '');341 for (var i = 0; i < repeatElems.length; ++i) {342 if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {343 var elem = repeatElems[i];344 var row = [];345 while (elem.nodeType != 8 || (elem.nodeValue &&346 !repeaterMatch(elem.nodeValue, repeater, exact))) {347 if (elem.nodeType == 1) {348 row.push(elem);349 }350 elem = elem.nextSibling;351 }352 multiRows.push(row);353 }354 }355 }356 var bindings = [];357 for (var i = 0; i < rows.length; ++i) {358 if (angular.getTestability) {359 matches.push.apply(360 matches,...

Full Screen

Full Screen

SeleniumExt.AngularJS.protractor.clientsidescripts.js

Source:SeleniumExt.AngularJS.protractor.clientsidescripts.js Github

copy

Full Screen

...98 * @return {Array.<Element>} The row of the repeater, or an array of elements99 * in the first row in the case of ng-repeat-start.100 */101 functions.findRepeaterRows = function(repeater, exact, index, using) {102 function repeaterMatch(ngRepeat, repeater, exact) {103 if (exact) {104 return ngRepeat.split(' track by ')[0].split(' as ')[0].split('|')[0].105 trim() == repeater;106 } else {107 return ngRepeat.indexOf(repeater) != -1;108 }109 }110 using = using || document;111 var prefixes = ['ng-', 'ng_', 'data-ng-', 'x-ng-', 'ng\\:'];112 var rows = [];113 for (var p = 0; p < prefixes.length; ++p) {114 var attr = prefixes[p] + 'repeat';115 var repeatElems = using.querySelectorAll('[' + attr + ']');116 attr = attr.replace(/\\/g, '');117 for (var i = 0; i < repeatElems.length; ++i) {118 if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {119 rows.push(repeatElems[i]);120 }121 }122 }123 /* multiRows is an array of arrays, where each inner array contains124 one row of elements. */125 var multiRows = [];126 for (var p = 0; p < prefixes.length; ++p) {127 var attr = prefixes[p] + 'repeat-start';128 var repeatElems = using.querySelectorAll('[' + attr + ']');129 attr = attr.replace(/\\/g, '');130 for (var i = 0; i < repeatElems.length; ++i) {131 if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {132 var elem = repeatElems[i];133 var row = [];134 while (elem.nodeType != 8 ||135 !repeaterMatch(elem.nodeValue, repeater, exact)) {136 if (elem.nodeType == 1) {137 row.push(elem);138 }139 elem = elem.nextSibling;140 }141 multiRows.push(row);142 }143 }144 }145 var row = rows[index] || [], multiRow = multiRows[index] || [];146 return [].concat(row, multiRow);147 };148 /**149 * Find all rows of an ng-repeat.150 *151 * @param {string} repeater The text of the repeater, e.g. 'cat in cats'.152 * @param {boolean} exact Whether the repeater needs to be matched exactly153 * @param {Element} using The scope of the search.154 *155 * @return {Array.<Element>} All rows of the repeater.156 */157 functions.findAllRepeaterRows = function(repeater, exact, using) {158 function repeaterMatch(ngRepeat, repeater, exact) {159 if (exact) {160 return ngRepeat.split(' track by ')[0].split(' as ')[0].split('|')[0].161 trim() == repeater;162 } else {163 return ngRepeat.indexOf(repeater) != -1;164 }165 }166 using = using || document;167 var rows = [];168 var prefixes = ['ng-', 'ng_', 'data-ng-', 'x-ng-', 'ng\\:'];169 for (var p = 0; p < prefixes.length; ++p) {170 var attr = prefixes[p] + 'repeat';171 var repeatElems = using.querySelectorAll('[' + attr + ']');172 attr = attr.replace(/\\/g, '');173 for (var i = 0; i < repeatElems.length; ++i) {174 if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {175 rows.push(repeatElems[i]);176 }177 }178 }179 for (var p = 0; p < prefixes.length; ++p) {180 var attr = prefixes[p] + 'repeat-start';181 var repeatElems = using.querySelectorAll('[' + attr + ']');182 attr = attr.replace(/\\/g, '');183 for (var i = 0; i < repeatElems.length; ++i) {184 if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {185 var elem = repeatElems[i];186 while (elem.nodeType != 8 ||187 !repeaterMatch(elem.nodeValue, repeater, exact)) {188 if (elem.nodeType == 1) {189 rows.push(elem);190 }191 elem = elem.nextSibling;192 }193 }194 }195 }196 return rows;197 };198 /**199 * Find an element within an ng-repeat by its row and column.200 *201 * @param {string} repeater The text of the repeater, e.g. 'cat in cats'.202 * @param {boolean} exact Whether the repeater needs to be matched exactly203 * @param {number} index The row index.204 * @param {string} binding The column binding, e.g. '{{cat.name}}'.205 * @param {Element} using The scope of the search.206 * @param {string} rootSelector The selector to use for the root app element.207 *208 * @return {Array.<Element>} The element in an array.209 */210 functions.findRepeaterElement = function(repeater, exact, index, binding, using, rootSelector) {211 function repeaterMatch(ngRepeat, repeater, exact) {212 if (exact) {213 return ngRepeat.split(' track by ')[0].split(' as ')[0].split('|')[0].214 trim() == repeater;215 } else {216 return ngRepeat.indexOf(repeater) != -1;217 }218 }219 var matches = [];220 var root = document.querySelector(rootSelector || 'body');221 using = using || document;222 var rows = [];223 var prefixes = ['ng-', 'ng_', 'data-ng-', 'x-ng-', 'ng\\:'];224 for (var p = 0; p < prefixes.length; ++p) {225 var attr = prefixes[p] + 'repeat';226 var repeatElems = using.querySelectorAll('[' + attr + ']');227 attr = attr.replace(/\\/g, '');228 for (var i = 0; i < repeatElems.length; ++i) {229 if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {230 rows.push(repeatElems[i]);231 }232 }233 }234 /* multiRows is an array of arrays, where each inner array contains235 one row of elements. */236 var multiRows = [];237 for (var p = 0; p < prefixes.length; ++p) {238 var attr = prefixes[p] + 'repeat-start';239 var repeatElems = using.querySelectorAll('[' + attr + ']');240 attr = attr.replace(/\\/g, '');241 for (var i = 0; i < repeatElems.length; ++i) {242 if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {243 var elem = repeatElems[i];244 var row = [];245 while (elem.nodeType != 8 || (elem.nodeValue &&246 !repeaterMatch(elem.nodeValue, repeater, exact))) {247 if (elem.nodeType == 1) {248 row.push(elem);249 }250 elem = elem.nextSibling;251 }252 multiRows.push(row);253 }254 }255 }256 var row = rows[index];257 var multiRow = multiRows[index];258 var bindings = [];259 if (row) {260 if (angular.getTestability) {261 matches.push.apply(262 matches,263 angular.getTestability(root).findBindings(row, binding));264 } else {265 if (row.className.indexOf('ng-binding') != -1) {266 bindings.push(row);267 }268 var childBindings = row.getElementsByClassName('ng-binding');269 for (var i = 0; i < childBindings.length; ++i) {270 bindings.push(childBindings[i]);271 }272 }273 }274 if (multiRow) {275 for (var i = 0; i < multiRow.length; ++i) {276 var rowElem = multiRow[i];277 if (angular.getTestability) {278 matches.push.apply(279 matches,280 angular.getTestability(root).findBindings(rowElem, binding));281 } else {282 if (rowElem.className.indexOf('ng-binding') != -1) {283 bindings.push(rowElem);284 }285 var childBindings = rowElem.getElementsByClassName('ng-binding');286 for (var j = 0; j < childBindings.length; ++j) {287 bindings.push(childBindings[j]);288 }289 }290 }291 }292 for (var i = 0; i < bindings.length; ++i) {293 var dataBinding = angular.element(bindings[i]).data('$binding');294 if (dataBinding) {295 var bindingName = dataBinding.exp || dataBinding[0].exp || dataBinding;296 if (bindingName.indexOf(binding) != -1) {297 matches.push(bindings[i]);298 }299 }300 }301 return matches;302 };303 /**304 * Find the elements in a column of an ng-repeat.305 *306 * @param {string} repeater The text of the repeater, e.g. 'cat in cats'.307 * @param {boolean} exact Whether the repeater needs to be matched exactly308 * @param {string} binding The column binding, e.g. '{{cat.name}}'.309 * @param {Element} using The scope of the search.310 * @param {string} rootSelector The selector to use for the root app element.311 *312 * @return {Array.<Element>} The elements in the column.313 */314 functions.findRepeaterColumn = function(repeater, exact, binding, using, rootSelector) {315 function repeaterMatch(ngRepeat, repeater, exact) {316 if (exact) {317 return ngRepeat.split(' track by ')[0].split(' as ')[0].split('|')[0].318 trim() == repeater;319 } else {320 return ngRepeat.indexOf(repeater) != -1;321 }322 }323 var matches = [];324 var root = document.querySelector(rootSelector || 'body');325 using = using || document;326 var rows = [];327 var prefixes = ['ng-', 'ng_', 'data-ng-', 'x-ng-', 'ng\\:'];328 for (var p = 0; p < prefixes.length; ++p) {329 var attr = prefixes[p] + 'repeat';330 var repeatElems = using.querySelectorAll('[' + attr + ']');331 attr = attr.replace(/\\/g, '');332 for (var i = 0; i < repeatElems.length; ++i) {333 if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {334 rows.push(repeatElems[i]);335 }336 }337 }338 /* multiRows is an array of arrays, where each inner array contains339 one row of elements. */340 var multiRows = [];341 for (var p = 0; p < prefixes.length; ++p) {342 var attr = prefixes[p] + 'repeat-start';343 var repeatElems = using.querySelectorAll('[' + attr + ']');344 attr = attr.replace(/\\/g, '');345 for (var i = 0; i < repeatElems.length; ++i) {346 if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {347 var elem = repeatElems[i];348 var row = [];349 while (elem.nodeType != 8 || (elem.nodeValue &&350 !repeaterMatch(elem.nodeValue, repeater, exact))) {351 if (elem.nodeType == 1) {352 row.push(elem);353 }354 elem = elem.nextSibling;355 }356 multiRows.push(row);357 }358 }359 }360 var bindings = [];361 for (var i = 0; i < rows.length; ++i) {362 if (angular.getTestability) {363 matches.push.apply(364 matches,...

Full Screen

Full Screen

ng-repeater.js

Source:ng-repeater.js Github

copy

Full Screen

...140 helpers.join(';') + String.fromCharCode(59) +141 ' return (' + fun.toString() + ').apply(this, arguments);');142}143*/144function repeaterMatch(ngRepeat, repeater, exact) {145 if (exact) {146 return ngRepeat.split(' track by ')[0].split(' as ')[0].split('|')[0].147 split('=')[0].trim() == repeater;148 } else {149 return ngRepeat.indexOf(repeater) != -1;150 }151}152function findRepeaterRows(repeater, exact, index, using) {153 using = using || document;154 var prefixes = ['ng-', 'ng_', 'data-ng-', 'x-ng-', 'ng\\:'];155 var rows = [];156 for (var p = 0; p < prefixes.length; ++p) {157 var attr = prefixes[p] + 'repeat';158 var repeatElems = using.querySelectorAll('[' + attr + ']');159 attr = attr.replace(/\\/g, '');160 for (var i = 0; i < repeatElems.length; ++i) {161 if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {162 rows.push(repeatElems[i]);163 }164 }165 }166 /* multiRows is an array of arrays, where each inner array contains167 one row of elements. */168 var multiRows = [];169 for (var p = 0; p < prefixes.length; ++p) {170 var attr = prefixes[p] + 'repeat-start';171 var repeatElems = using.querySelectorAll('[' + attr + ']');172 attr = attr.replace(/\\/g, '');173 for (var i = 0; i < repeatElems.length; ++i) {174 if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {175 var elem = repeatElems[i];176 var row = [];177 while (elem.nodeType != 8 ||178 !repeaterMatch(elem.nodeValue, repeater)) {179 if (elem.nodeType == 1) {180 row.push(elem);181 }182 elem = elem.nextSibling;183 }184 multiRows.push(row);185 }186 }187 }188 var row = rows[index] || [], multiRow = multiRows[index] || [];189 return [].concat(row, multiRow);190}191//functions.findRepeaterRows = wrapWithHelpers(findRepeaterRows, repeaterMatch); 192function findAllRepeaterRows(repeater, exact, using) {193 using = using || document;194 var rows = [];195 var prefixes = ['ng-', 'ng_', 'data-ng-', 'x-ng-', 'ng\\:'];196 for (var p = 0; p < prefixes.length; ++p) {197 var attr = prefixes[p] + 'repeat';198 var repeatElems = using.querySelectorAll('[' + attr + ']');199 attr = attr.replace(/\\/g, '');200 for (var i = 0; i < repeatElems.length; ++i) {201 if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {202 rows.push(repeatElems[i]);203 }204 }205 }206 for (var p = 0; p < prefixes.length; ++p) {207 var attr = prefixes[p] + 'repeat-start';208 var repeatElems = using.querySelectorAll('[' + attr + ']');209 attr = attr.replace(/\\/g, '');210 for (var i = 0; i < repeatElems.length; ++i) {211 if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {212 var elem = repeatElems[i];213 while (elem.nodeType != 8 ||214 !repeaterMatch(elem.nodeValue, repeater)) {215 if (elem.nodeType == 1) {216 rows.push(elem);217 }218 elem = elem.nextSibling;219 }220 }221 }222 }223 return rows;224}225//functions.findAllRepeaterRows = wrapWithHelpers(findAllRepeaterRows, repeaterMatch);226function findRepeaterElement(repeater, exact, index, binding, using, rootSelector) {227 var matches = [];228 var root = document.querySelector(rootSelector || 'body');229 using = using || document;230 var rows = [];231 var prefixes = ['ng-', 'ng_', 'data-ng-', 'x-ng-', 'ng\\:'];232 for (var p = 0; p < prefixes.length; ++p) {233 var attr = prefixes[p] + 'repeat';234 var repeatElems = using.querySelectorAll('[' + attr + ']');235 attr = attr.replace(/\\/g, '');236 for (var i = 0; i < repeatElems.length; ++i) {237 if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {238 rows.push(repeatElems[i]);239 }240 }241 }242 /* multiRows is an array of arrays, where each inner array contains243 one row of elements. */244 var multiRows = [];245 for (var p = 0; p < prefixes.length; ++p) {246 var attr = prefixes[p] + 'repeat-start';247 var repeatElems = using.querySelectorAll('[' + attr + ']');248 attr = attr.replace(/\\/g, '');249 for (var i = 0; i < repeatElems.length; ++i) {250 if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {251 var elem = repeatElems[i];252 var row = [];253 while (elem.nodeType != 8 || (elem.nodeValue &&254 !repeaterMatch(elem.nodeValue, repeater))) {255 if (elem.nodeType == 1) {256 row.push(elem);257 }258 elem = elem.nextSibling;259 }260 multiRows.push(row);261 }262 }263 }264 var row = rows[index];265 var multiRow = multiRows[index];266 var bindings = [];267 if (row) {268 //if (angular.getTestability) {269 // matches.push.apply(270 // matches,271 // angular.getTestability(root).findBindings(row, binding));272 //} else {273 if (row.className.indexOf('ng-binding') != -1) {274 bindings.push(row);275 }276 var childBindings = row.getElementsByClassName('ng-binding');277 for (var i = 0; i < childBindings.length; ++i) {278 bindings.push(childBindings[i]);279 }280 //}281 }282 if (multiRow) {283 for (var i = 0; i < multiRow.length; ++i) {284 var rowElem = multiRow[i];285 //if (angular.getTestability) {286 // matches.push.apply(287 // matches,288 // angular.getTestability(root).findBindings(rowElem, binding));289 //} else {290 if (rowElem.className.indexOf('ng-binding') != -1) {291 bindings.push(rowElem);292 }293 var childBindings = rowElem.getElementsByClassName('ng-binding');294 for (var j = 0; j < childBindings.length; ++j) {295 bindings.push(childBindings[j]);296 }297 //}298 }299 }300 for (var i = 0; i < bindings.length; ++i) {301 var dataBinding = angular.element(bindings[i]).data('$binding');302 if (dataBinding) {303 var bindingName = dataBinding.exp || dataBinding[0].exp || dataBinding;304 if (bindingName.indexOf(binding) != -1) {305 matches.push(bindings[i]);306 }307 }308 }309 return matches;310}311//functions.findRepeaterElement = wrapWithHelpers(findRepeaterElement, repeaterMatch);312function findRepeaterColumn(repeater, exact, binding, using, rootSelector) {313 var matches = [];314 var root = document.querySelector(rootSelector || 'body');315 using = using || document;316 var rows = [];317 var prefixes = ['ng-', 'ng_', 'data-ng-', 'x-ng-', 'ng\\:'];318 for (var p = 0; p < prefixes.length; ++p) {319 var attr = prefixes[p] + 'repeat';320 var repeatElems = using.querySelectorAll('[' + attr + ']');321 attr = attr.replace(/\\/g, '');322 for (var i = 0; i < repeatElems.length; ++i) {323 if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {324 rows.push(repeatElems[i]);325 }326 }327 }328 /* multiRows is an array of arrays, where each inner array contains329 one row of elements. */330 var multiRows = [];331 for (var p = 0; p < prefixes.length; ++p) {332 var attr = prefixes[p] + 'repeat-start';333 var repeatElems = using.querySelectorAll('[' + attr + ']');334 attr = attr.replace(/\\/g, '');335 for (var i = 0; i < repeatElems.length; ++i) {336 if (repeaterMatch(repeatElems[i].getAttribute(attr), repeater, exact)) {337 var elem = repeatElems[i];338 var row = [];339 while (elem.nodeType != 8 || (elem.nodeValue &&340 !repeaterMatch(elem.nodeValue, repeater))) {341 if (elem.nodeType == 1) {342 row.push(elem);343 }344 elem = elem.nextSibling;345 }346 multiRows.push(row);347 }348 }349 }350 var bindings = [];351 for (var i = 0; i < rows.length; ++i) {352 //if (angular.getTestability) {353 // matches.push.apply(354 // matches,...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var repeaterMatch = require('protractor-repeater-match');2var EC = protractor.ExpectedConditions;3describe('protractor repeater match', function() {4 it('should match repeater', function() {5 var repeater = repeaterMatch('todo in todos | filter:statusFilter track by $index');6 var todo = repeater('todo in todos').row(1).column('todo.done');7 browser.wait(EC.visibilityOf(todo), 5000);8 todo.click();9 });10});

Full Screen

Using AI Code Generation

copy

Full Screen

1var repeaterMatch = require('protractor-repeater-match');2var EC = protractor.ExpectedConditions;3describe('Protractor Repeater Match', function() {4 it('should match repeater values', function() {5 element(by.model('yourName')).sendKeys('Protractor');6 var greeting = element(by.binding('yourName'));7 browser.wait(EC.textToBePresentInElement(greeting, 'Protractor'), 5000);8 var repeater = repeaterMatch('greeting in greetings', 'Hello Protractor!');9 expect(element(by.repeater(repeater)).isPresent()).toBeTruthy();10 });11});

Full Screen

Using AI Code Generation

copy

Full Screen

1var repeaterMatch = require('protractor-repeater-match');2var EC = protractor.ExpectedConditions;3describe('Protractor repeater match', function() {4 it('should match repeater row', function() {5 var repeater = 'todo in todoList.todos';6 var row = repeaterMatch(repeater, {text: 'write first protractor test'});7 expect(row.element(by.model('todo.done')).isSelected()).toBe(false);8 row.element(by.model('todo.done')).click();9 expect(row.element(by.model('todo.done')).isSelected()).toBe(true);10 });11});

Full Screen

Using AI Code Generation

copy

Full Screen

1var repeaterMatch = require('protractor-repeater-match');2var EC = protractor.ExpectedConditions;3var helper = require('../helpers/helper.js');4var test = require('../testData/testData.json');5describe('Protractor repeater match', function () {6 var firstRepeater = element(by.repeater('result in memory'));7 var secondRepeater = element(by.repeater('result in memory'));8 it('should match first repeater with second repeater', function () {9 browser.get(test.testUrl);10 helper.waitForElementToBeClickable(element(by.model('first')));11 helper.enterText(element(by.model('first')), test.firstNumber);12 helper.enterText(element(by.model('second')), test.secondNumber);13 helper.clickElement(element(by.id('gobutton')));14 helper.waitForElementToBeClickable(element(by.model('first')));15 helper.enterText(element(by.model('first')), test.firstNumber);16 helper.enterText(element(by.model('second')), test.secondNumber);17 helper.clickElement(element(by.id('gobutton')));18 helper.waitForElementToBeClickable(element(by.model('first')));19 helper.enterText(element(by.model('first')), test.firstNumber);20 helper.enterText(element(by.model('second')), test.secondNumber);21 helper.clickElement(element(by.id('gobutton')));22 helper.waitForElementToBeClickable(element(by.model('first')));23 helper.enterText(element(by.model('first')), test.firstNumber);24 helper.enterText(element(by.model('second')), test.secondNumber);25 helper.clickElement(element(by.id('gobutton')));26 helper.waitForElementToBeClickable(element(by.model('first')));27 helper.enterText(element(by.model('first')), test.firstNumber);28 helper.enterText(element(by.model('second')), test.secondNumber);29 helper.clickElement(element(by.id('gobutton')));30 helper.waitForElementToBeClickable(element(by.model('first')));31 helper.enterText(element(by.model('first')), test.firstNumber);32 helper.enterText(element(by.model('second')), test.secondNumber);33 helper.clickElement(element(by.id('gobutton')));34 helper.waitForElementToBeClickable(element(by.model('first')));35 helper.enterText(element(by.model('first')), test.firstNumber);36 helper.enterText(element(by.model('second')), test.secondNumber);37 helper.clickElement(element(by.id('gobutton')));38 helper.waitForElementToBeClickable(element(by.model('first')));39 helper.enterText(element(by.model('first')), test.firstNumber);

Full Screen

Using AI Code Generation

copy

Full Screen

1var repeaterMatch = function (repeater, string) {2 var using = protractor.getInstance().driver.findElement;3 return function (rootEl) {4 var deferred = protractor.promise.defer();5 using(rootEl).findElements(protractor.By.repeater(repeater)).then(function (arr) {6 var found = false;7 arr.forEach(function (element) {8 element.getText().then(function (text) {9 if (text.indexOf(string) > -1) {10 found = true;11 deferred.fulfill(element);12 }13 });14 });15 if (!found) {16 deferred.reject('Could not find element with string ' + string);17 }18 });19 return deferred.promise;20 };21};22var repeaterMatch = function (repeater, string) {23 var using = protractor.getInstance().driver.findElement;24 return function (rootEl) {25 var deferred = protractor.promise.defer();26 using(rootEl).findElements(protractor.By.repeater(repeater)).then(function (arr) {27 var found = false;28 arr.forEach(function (element) {29 element.getText().then(function (text) {30 if (text.indexOf(string) > -1) {31 found = true;32 deferred.fulfill(element);33 }34 });35 });36 if (!found) {37 deferred.reject('Could not find element with string ' + string);38 }39 });40 return deferred.promise;41 };42};43var repeaterMatch = function (repeater, string) {44 var using = protractor.getInstance().driver.findElement;45 return function (rootEl) {46 var deferred = protractor.promise.defer();47 using(rootEl).findElements(protractor.By.repeater(repeater)).then(function (arr) {48 var found = false;49 arr.forEach(function (element) {50 element.getText().then(function (text) {51 if (text.indexOf(string) > -1) {52 found = true;53 deferred.fulfill(element);54 }55 });56 });57 if (!found) {58 deferred.reject('Could not find element with string ' + string);59 }60 });61 return deferred.promise;62 };63};64var repeaterMatch = function (repeater, string) {65 var using = protractor.getInstance().driver

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test', function() {2 it('should get the number of rows in the repeater', function() {3 var rows = element.all(by.repeater('cust in Customers'));4 rows.count().then(function(count){5 console.log(count);6 });7 });8});9describe('Test', function() {10 it('should get the text of each row in the repeater', function() {11 var rows = element.all(by.repeater('cust in Customers'));12 rows.each(function(row){13 row.getText().then(function(text){14 console.log(text);15 });16 });17 });18});19describe('Test', function() {20 it('should get the text of each row in the repeater', function() {21 var rows = element.all(by.repeater('cust in Customers'));22 rows.each(function(row){23 row.getText().then(function(text){24 console.log(text.split(' ')[0]);25 });26 });27 });28});29describe('Test', function() {30 it('should get the text of each row in the repeater', function() {31 var rows = element.all(by.repeater('cust in Customers'));32 rows.get(0).getText().then(function(text){33 console.log(text.split(' ')[0]);34 });35 });36});

Full Screen

Using AI Code Generation

copy

Full Screen

1var repeater = 'item in items';2var repeaterMatch = function(repeater) {3 return function(elem, index) {4 return elem.getAttribute('ng-repeat').then(function(attr) {5 return attr == repeater;6 });7 }8};9element.all(by.css('*')).filter(repeaterMatch(repeater)).first().getText().then(function(text) {10 console.log(text);11});12var repeater = 'item in items';13var repeaterMatch = function(repeater) {14 return function(elem, index) {15 return elem.getAttribute('ng-repeat').then(function(attr) {16 return attr == repeater;17 });18 }19};20element.all(by.css('*')).filter(repeaterMatch(repeater)).first().getText().then(function(text) {21 console.log(text);22});23var repeater = 'item in items';24var repeaterMatch = function(repeater) {25 return function(elem, index) {26 return elem.getAttribute('ng-repeat').then(function(attr) {27 return attr == repeater;28 });29 }30};31element.all(by.css('*')).filter(repeaterMatch(repeater)).first().getText().then(function(text) {32 console.log(text);33});34var repeater = 'item in items';35var repeaterMatch = function(repeater) {36 return function(elem, index) {37 return elem.getAttribute('ng-repeat').then(function(attr) {38 return attr == repeater;39 });40 }41};42element.all(by.css('*')).filter(repeaterMatch(repeater)).first().getText().then(function(text) {43 console.log(text);44});45var repeater = 'item in items';

Full Screen

Selenium Protractor Tutorial

Protractor is developed by Google Developers to test Angular and AngularJS code. Today, it is used to test non-Angular applications as well. It performs a real-world user-like test against your application in a real browser. It comes under an end-to-end testing framework. As of now, Selenium Protractor has proved to be a popular framework for end-to-end automation for AngularJS.

Let’s talk about what it does:

  • Protractor, built on WebDriver JS (Selenium), offers Angular-specific locator strategies.
  • It helps to construct automated tests for applications other than Angular JS and is not just intended to test AngularJS applications.
  • Page object design pattern is supported by Protractor Selenium, which improves in producing clear and legible code. Automation testers need to write clean code.
  • Frameworks like Jasmine, Cucumber, and others are fully integrated with Protractor.

Chapters:

Protractor is a JavaScript framework, end-to-end test automation framework for Angular and AngularJS applications.

Protractor Selenium provides new locator methods that actually make it easier to find elements in the DOM.

Two files are required to execute Protractor Selenium tests for end-to-end automation: Specs & Config. Go through the link above to understand in a better way.

To carry out extensive, automated cross browser testing, you can't imagine installing thousands of the available browsers on your own workstation. The only way to increase browser usage is through remote execution on the cloud. To execute your automation test scripts across a variety of platforms and browser versions, LambdaTest offers more than 3000 browsers.

We recommend Selenium for end-to-end automation for AngularJS because both are maintained and owned by Google, and they build JavaScript test automation framework to handle AngularJS components in a way that better matches how developers use it.

For scripting, selenium locators are essential since if they're off, your automation scripts won't run. Therefore, in any testing framework, these Selenium locators are the foundation of your Selenium test automation efforts.

To make sure that your Selenium automation tests function as intended, debugging can be an effective option. Check the blog to know more.

Get familiar with global variables that are majorly used in locating the DOM elements with examples for better understanding of these Selenium locators in protractor.

If you are not familiar with writing Selenium test automation on Protractor, here is a blog for you to get you understand in depth.

Selenium tests are asynchronous and there are various reasons for a timeout to occur in a Protractor test. Find out how to handle timeouts in this Protractor tutorial.

In this Protractor tutorial, learn how to handle frames or iframes in Selenium with Protractor for automated browser testing.

Handle alerts and popups in Protractor more efficiently. It can be confusing. Here's a simple guide to understand how to handle alerts and popups in Selenium.

Run Protractor automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful