How can I loop this code to repeat and set a different variable for every occurrence of the class 'auto-date-time' ?
tell application "Safari"
set myValue to do JavaScript "document.getElementsByClassName('auto-date-time')[0].innerHTML;" in current tab of window 1
end tell
e.g : myValue1 document.getElementsByClassName('auto-date-time')[1] MyValue2 document.getElementsByClassName('auto-date-time')[2] MyValue3 document.getElementsByClassName('auto-date-time')[3
I know this work fine
tell application "Safari"
set myValue to do JavaScript "var outPut=[]; var arr=document.getElementsByClassName('sortable fraudScoringTransactionCCSummary');for (var i in arr) {outPut.push(arr[i].innerHTML)};outPut;" in current tab of window 1
end tell
But I'm trying to do it different, can that be done?
I tried this which is working but obviously seems pretty bad + that wouldn't fix the issue of the variable
repeat with counter from 1 to 10
tell application "Safari"
set myValue to do JavaScript "document.getElementsByClassName('auto-date-time')[" & counter & "].innerHTML;" in current tab of window 1
end tell
if myValue = missing value then
exit repeat
end if
end repeat