{"action":"created","issue":{"url":"https://api.github.com/repos/theintern/intern/issues/538","labels_url":"https://api.github.com/repos/theintern/intern/issues/538/labels{/name}","comments_url":"https://api.github.com/repos/theintern/intern/issues/538/comments","events_url":"https://api.github.com/repos/theintern/intern/issues/538/events","html_url":"https://github.com/theintern/intern/issues/538","id":118247952,"number":538,"title":"iterating over elements using Intern/Leadfoot...","user":{"login":"papowell","id":702261,"avatar_url":"https://avatars.githubusercontent.com/u/702261?v=3","gravatar_id":"","url":"https://api.github.com/users/papowell","html_url":"https://github.com/papowell","followers_url":"https://api.github.com/users/papowell/followers","following_url":"https://api.github.com/users/papowell/following{/other_user}","gists_url":"https://api.github.com/users/papowell/gists{/gist_id}","starred_url":"https://api.github.com/users/papowell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/papowell/subscriptions","organizations_url":"https://api.github.com/users/papowell/orgs","repos_url":"https://api.github.com/users/papowell/repos","events_url":"https://api.github.com/users/papowell/events{/privacy}","received_events_url":"https://api.github.com/users/papowell/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-11-22T06:59:09Z","updated_at":"2015-11-25T10:18:59Z","closed_at":"2015-11-23T21:22:59Z","body":"Hello,\r\nThere are 2 places below where code (in Javascript) is never executed although it appears as though it should.  See code below were the comment says  'THIS CODE NEVER GETS EXECUTED'.\r\n\r\nI created the 2 files 'a.html' and 'b.html' to ultimately be added to a page as an iframe.  I'd like to iterate through the iframes, get the ID of each iframe, and then use the ID to get the content of each iframe for testing.  I happen to be in an environment where the IDs are generate dynamically.\r\n\r\nHow do I do this using the Javascript testing framework Intern?\r\n\r\nFile: a.html\r\n==========================\r\n```html\r\n<!DOCTYPE html>\r\n<html lang=\"en\">\r\n<head>\r\n    <meta charset=\"UTF-8\">\r\n    <title>A Title</title>\r\n</head>\r\n<body>\r\nGot A here\r\n</body>\r\n</html>\r\n```\r\n=======================\r\n\r\nFile: b.html\r\n=======================\r\n```html\r\n<!DOCTYPE html>\r\n<html lang=\"en\">\r\n<head>\r\n    <meta charset=\"UTF-8\">\r\n    <title>B Title</title>\r\n</head>\r\n<body>\r\nGot B here\r\n</body>\r\n</html>\r\n```\r\n=======================\r\n\r\nI created a file index.html that loads the files above...\r\nFile: index.html\r\n=======================\r\n```html\r\n<!DOCTYPE html>\r\n<html lang=\"en\">\r\n<head>\r\n    <meta charset=\"UTF-8\">\r\n    <title>Main</title>\r\n</head>\r\n<body>\r\n\r\n<iframe id=\"a1\" width=\"100\" height=\"100\" src=\"a.html\"></iframe>\r\n<iframe id=\"b1\" width=\"100\" height=\"100\" src=\"b.html\"></iframe>\r\n</body>\r\n</html>\r\n```\r\n======================\r\n\r\n... and ran the following intern tests\r\nfile: testFrames.js\r\n======================\r\n```javascript\r\ndefine([\r\n    'intern!object',\r\n    'intern/chai!assert'\r\n], function (registerSuite, assert) {\r\n    registerSuite({\r\n        name: 'is this working?',\r\n        'Check page titles': function()\r\n        {\r\n            return this.remote.get(require.toUrl(\"html/index.html\"))\r\n                .findAllByTagName(\"iframe\")\r\n                .switchToFrame()  // hopefully here, all the frames will be switched\r\n                .getPageTitle()      // ...so I can eventually get the title of each frame.\r\n                .then(function(title)\r\n                {\r\n                    // THIS CODE NEVER GETS EXECUTED\r\n                    console.log(\"here is the title: \",title);\r\n                    // make assertions here to verify all is well.\r\n                })\r\n                .end()\r\n            ;\r\n        }\r\n\r\n        'Iterating through frames': function () {\r\n            var command = this.remote;\r\n            command = command.get(require.toUrl( \"html/index.html\"))\r\n                .findAllByTagName(\"iframe\")\r\n                .then(function(iframes)\r\n                {\r\n                    assert( iframes.length== 2);\r\n                    for (var i=0;i<iframes.length;i++)\r\n                    {\r\n                        var frame = iframes[i];\r\n                        console.log(\"got frame id: \", frame.elementId);\r\n                        frame.getAttribute(\"id\").then(function(id)\r\n                        {\r\n                            // an elementId is not the same as an attribute id of an element --- ARGH!!!\r\n                            console.log(\"got id: \", id);\r\n                            command = command\r\n                                .findById(id)\r\n                                .switchToFrame(id)\r\n                                .getPageTitle()\r\n                                .then(function(text)\r\n                                {\r\n                                   // THIS CODE NEVER GETS EXECUTED\r\n                                    console.log(\"something should be here: \");\r\n                                    console.log(\"text value: \", text);\r\n                                    // make assertions here to verify all is well.\r\n                                })\r\n                                .end();\r\n                            return command;\r\n                        })\r\n                    }\r\n                })\r\n                .end()\r\n            ;\r\n        return command;\r\n        }\r\n    });\r\n});\r\n```\r\n======================"},"comment":{"url":"https://api.github.com/repos/theintern/intern/issues/comments/159562632","html_url":"https://github.com/theintern/intern/issues/538#issuecomment-159562632","issue_url":"https://api.github.com/repos/theintern/intern/issues/538","id":159562632,"user":{"login":"kitsonk","id":1282577,"avatar_url":"https://avatars.githubusercontent.com/u/1282577?v=3","gravatar_id":"","url":"https://api.github.com/users/kitsonk","html_url":"https://github.com/kitsonk","followers_url":"https://api.github.com/users/kitsonk/followers","following_url":"https://api.github.com/users/kitsonk/following{/other_user}","gists_url":"https://api.github.com/users/kitsonk/gists{/gist_id}","starred_url":"https://api.github.com/users/kitsonk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kitsonk/subscriptions","organizations_url":"https://api.github.com/users/kitsonk/orgs","repos_url":"https://api.github.com/users/kitsonk/repos","events_url":"https://api.github.com/users/kitsonk/events{/privacy}","received_events_url":"https://api.github.com/users/kitsonk/received_events","type":"User","site_admin":false},"created_at":"2015-11-25T10:18:59Z","updated_at":"2015-11-25T10:18:59Z","body":"All three of them answer questions on StackOverflow in their spare time, because they care, just like the other people who have contributed to Intern.\r\n\r\nOften times if you don't receive an answer in any forum, it can be for a number of reasons, including that you are asking a obvious answer, or the question you are asking is not clear, or people, who are giving of their own spare time to help others are busy."}}