I am trying to load several links in a hidden iFrame, one after the other but an error occurs at this line
frame.contentDocument.getElementsByClassName('radiopad')[0].getElementsByTagName('input')[0].checked = true;
that states:
Uncaught TypeError: Cannot call method 'getElementsByTagName' of undefined
Essentially, I want to load a link in the iFrame, then fill the form on that page that loads in t and submit it(this code is tested and working) and then, once this has been completed, move on to doing the same thing with the next link. I am just currently not able to get the "document"(not sure if that is what is called) of the iFrame.
Here is my entire code snippet in case you need it.
frame = document.createElement('iframe');
frame.style.display = 'none'
document.body.appendChild(frame);
for (var i = 0; i < feedbackLinks.length; i++) {
frame.setAttribute('src', feedbackLinks[i]);
console.log(frame.contentDocument);
while (frame.src != 'http://feedback.ebay.com/ws/eBayISAPI.dll') {
frame.contentDocument.getElementsByClassName('radiopad')[0].getElementsByTagName('input')[0].checked = true;
frame.contentDocument.getElementById('comment00').value = 'Great Seller';
var starRatings = ['v4-15', 'v4-27', 'v4-32', 'v4-37'];
for (var ID = 0; ID < starRatings.length; ID++) {
if (frame.contentDocument.getElementById(starRatings[ID]) != null) {
frame.contentDocument.getElementById(starRatings[ID]).click();
}
}
frame.contentDocument.getElementById('but_formSave').click();
}
console.log("completed link " + (i + 1));
}
Thanks in advance :)