-4

I'm intercepting into an html page and need to find all anchors having "Select All" in their inner html.

I need to write a piece of JavaScript to find all the anchors and then Click them.

I'm going to write a javascript like this:

// there is no method like getElementByInnerHtml so I don't know what to do
var anc = document.getElementByInnerHtml('Select All');
anc.click();

I'm not able to use jquery or any other language specific methods. Only standard HTML DOM methods are available.

FLICKER
  • 6,439
  • 4
  • 45
  • 75

1 Answers1

0

I implemented the code and thanks @ChrisLove for hint.

Actually the code in the referred post was not correct and using below code I could do what I needed to do.

<script type="text/javascript">
    var x = document.getElementsByTagName("a");
    for (i = 0; i < x.length; i++) { 
        if (x[i].innerHTML == "Select All")
            x[i].click();
    }    
</script>

Note that you need to use getElementsByTagName not getElements which is mentioned in the other post.

FLICKER
  • 6,439
  • 4
  • 45
  • 75