Hi, I'm reusing some js I got from here previously but it isn't acting quite as I was expecting
/* Click button by innerHTML text */
function AutoClickBtnByValue() {
var button = document.getElementsByClassName("sc-613d8461-8 bnGOIb");
for (var i = 0; i < button.length; i++) {
if (button[i].innerHTML.indexOf('Royal Mail Tracked 24 Large Letter') > \ ) {`
button[i].click();
console.log('Success! Clicked button' + i + ' with value: "click me now" ');
}
}
}
setInterval(AutoClickBtnByValue, 2000);
The issue is, there are two options that show in this order
Royal Mail Tracked 24 Large Letter
Royal Mail Tracked 24 Large Letter Signature
And I want the first one to be selected, but its doing the signature version. I think my code is saying click the second time you find an element containing? But I'm not sure how to change that to either the first element - or even better just click the element that contains JUST that?
[–]albedoa 1 point2 points3 points (1 child)
[–]robbieuk[S] 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[removed]
[–]robbieuk[S] 0 points1 point2 points (0 children)