[Using Chimp.js – Synchronous style webdriverio API]
How can I properly iterate through my array of elements? Or, more specifically, how do I access the attributes of the elements themselves? I'm confused as to the .elements() function found in the API and how to extract the elements themselves from there.
var myItem;
var elemArray = browser.elements('.castMemberPicture').value;
console.log(elemArray);
for (myItem in elemArray){
console.log("myItem: " + myItem);
// I can log the JSON obj IDs successfully, but can’t seem to access elements like clientHeight, alt, ...
};
How do I access the attributes?
(output)
[ { ELEMENT: '0' },
{ ELEMENT: '1' },
{ ELEMENT: '2' },
{ ELEMENT: '3' }]
myItem: 0
myItem: 1
myItem: 2
myItem: 3
... calling to .ELEMENT gives undefined calls, so it's likely my use of the API / syntax.
I saw https://github.com/webdriverio/webdriverio/issues/273 but I can't get to access the attributes no matter what combination of .ELEMENT .value and function I try. Help?
note - if I try to explore the elements themselves by printing using console.log("myItem: " + JSON.stringify(elemArray[myItem].ELEMENT));
the output becomes
[ { ELEMENT: '0' },
{ ELEMENT: '1' },
{ ELEMENT: '2' },
{ ELEMENT: '3' }]
myItem: "0"
myItem: "1"
myItem: "2"
myItem: "3"