0

I am trying to press these buttons through click event

First Code (id 1)

<td id="UPDown_1">
<a href="javascript:void(0)" class="upMinus">
<img src="/alpha/images/up/minus.png" width="14px" alt="all"></a> 
<a href="javascript:void(0)" class="DownPlus">
<img src="/alpha/images/Down/plus.png" width="14px" alt="maximum"></a></td>

Second Code (id 2)

<td id="UPDown_2">
<a href="javascript:void(0)" class="upMinus">
<img src="/alpha/images/up/minus.png" width="14px" alt="all"></a> 
<a href="javascript:void(0)" class="DownPlus">
<img src="/alpha/images/Down/plus.png" width="14px" alt="maximum"></a></td>

I tried this code

For Each element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("img")
        If element.GetAttribute("alt") = "all" Then
            element.InvokeMember("click")
        End If
    Next

it's worked but of course pressed all the buttons

beshoy
  • 1
  • 3
  • Your last sentence is saying that everything is working? These aren't buttons, they are anchor. – the_lotus May 18 '17 at 11:51
  • All the buttons are pressed ... I need every one separately something like For Each element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("td") If element.GetAttribute("id") = "UPDown_1" Then element.GetAttribute("alt") = "all" Then element.InvokeMember("click") End If Next – beshoy May 18 '17 at 12:47
  • Maybe if you ask something like: How do I get a list of element inside a specific element. Which there's [some](http://stackoverflow.com/questions/1157258/find-specific-data-in-html-with-htmlelementcollection-and-webbrowser) [answers](http://stackoverflow.com/questions/20686488/getting-contents-of-specific-div-element) [about](http://stackoverflow.com/questions/5603164/webbrowser-control-get-element-by-type) [this](http://stackoverflow.com/questions/28344280/get-element-by-id-from-webbrowser-and-show-in-label) already. Hope this helps! – the_lotus May 18 '17 at 13:24
  • First of all, thank you for your response I don't have skills with writing codes..so please help if you can – beshoy May 19 '17 at 12:27
  • ' Dim doc As HtmlDocument = WebBrowser1.Document Dim col As HtmlElementCollection = doc.GetElementsByTagName("td") For Each element As HtmlElement In col Dim cls As String = element.GetAttribute("id") If (String.IsNullOrEmpty(cls) _ OrElse Not cls.Equals("UPDown_1")) Then **What will I write here?** End If Dim childDivs As HtmlElementCollection = element.Children.GetElementsByName("img") For Each childElement As HtmlElement In childDivs **What will I write here** – beshoy May 19 '17 at 12:28

0 Answers0