We can select any element of webpage using document.querySelector and loop through each element having same class with forEach function. Follow below example to understand it better:
flag = 0;
idtochoose = '';
document.querySelector('.ty-shipping-options__method input').forEach(function(node) {
console.log(node.id);if(node.checked){
flag = 1;
}
if(idtochoose == ''){
idtochoose = node.id;
}
});if(flag == 0){
setTimeout(function(){
document.getElementById(idtochoose).click();
},500);
}