{"action":"created","issue":{"url":"https://api.github.com/repos/angular/protractor/issues/2538","labels_url":"https://api.github.com/repos/angular/protractor/issues/2538/labels{/name}","comments_url":"https://api.github.com/repos/angular/protractor/issues/2538/comments","events_url":"https://api.github.com/repos/angular/protractor/issues/2538/events","html_url":"https://github.com/angular/protractor/issues/2538","id":108264412,"number":2538,"title":"Making ElementArrayFinder from an array of ElementFinders","user":{"login":"alecxe","id":1291983,"avatar_url":"https://avatars.githubusercontent.com/u/1291983?v=3","gravatar_id":"","url":"https://api.github.com/users/alecxe","html_url":"https://github.com/alecxe","followers_url":"https://api.github.com/users/alecxe/followers","following_url":"https://api.github.com/users/alecxe/following{/other_user}","gists_url":"https://api.github.com/users/alecxe/gists{/gist_id}","starred_url":"https://api.github.com/users/alecxe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alecxe/subscriptions","organizations_url":"https://api.github.com/users/alecxe/orgs","repos_url":"https://api.github.com/users/alecxe/repos","events_url":"https://api.github.com/users/alecxe/events{/privacy}","received_events_url":"https://api.github.com/users/alecxe/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/angular/protractor/labels/type:%20feature%20request","name":"type: feature request","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-09-25T05:08:06Z","updated_at":"2015-10-28T19:42:43Z","closed_at":null,"body":"This is basically a follow-up to the resolved SO topic: http://stackoverflow.com/questions/32599679/making-elementarrayfinder-from-an-array-of-elementfinders.\r\n\r\nWould it make sense to have `fromArray()` method available on `ElementArrayFinder` built-in? \r\n\r\nThanks. \r\n\r\nFeel free to close this one if you think this is not something we can benefit from."},"comment":{"url":"https://api.github.com/repos/angular/protractor/issues/comments/151968485","html_url":"https://github.com/angular/protractor/issues/2538#issuecomment-151968485","issue_url":"https://api.github.com/repos/angular/protractor/issues/2538","id":151968485,"user":{"login":"hankduan","id":1059345,"avatar_url":"https://avatars.githubusercontent.com/u/1059345?v=3","gravatar_id":"","url":"https://api.github.com/users/hankduan","html_url":"https://github.com/hankduan","followers_url":"https://api.github.com/users/hankduan/followers","following_url":"https://api.github.com/users/hankduan/following{/other_user}","gists_url":"https://api.github.com/users/hankduan/gists{/gist_id}","starred_url":"https://api.github.com/users/hankduan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hankduan/subscriptions","organizations_url":"https://api.github.com/users/hankduan/orgs","repos_url":"https://api.github.com/users/hankduan/repos","events_url":"https://api.github.com/users/hankduan/events{/privacy}","received_events_url":"https://api.github.com/users/hankduan/received_events","type":"User","site_admin":false},"created_at":"2015-10-28T19:42:43Z","updated_at":"2015-10-28T19:42:43Z","body":"I'm still not convinced this function is needed. Looking at your stackoverflow issue, here's your original code:\r\n\r\n```javascript\r\nvar i = 0;\r\nvar el = element.all(by.css('ul li a'));\r\nvar tableItems = [];\r\n(function loop() {\r\n    el.get(i).getText().then(function(text){\r\n        if(text){\r\n            tableItems.push(el.get(i));\r\n            i+=1;\r\n            loop();\r\n        }\r\n    });\r\n}());\r\n// Now you want to convert tableItems to an ElementArrayFinder like:\r\n// var myEls = ElementArrayFinder.fromArray(tableItems);\r\n```\r\n\r\nYou can just rewrite it with filter:\r\n\r\n```javascript\r\nvar els = element.all(by.css('ul li a'));\r\nvar filteredEls = els.filter(function(el) {\r\n  return el.getText().then(function(text) {\r\n    return !!text;\r\n  })\r\n});\r\n// filteredEls is exactly what you want\r\n```\r\n\r\nThe rewrite makes the code shorter and easier to understand. Can you provide me with an example where the `fromArray` method makes life easier?"}}