I am working on a personal project that will help my speed things up. I'm fairly good at figuring out how to click buttons with an id where you getelementby id and then invokemember("click"); but this one I am trying to click is somewhat over my head. I have done lots of research and multiple attempts but still have no luck. By the way, the webpage changes some when the button (image) is clicked; it does not redirect the webbrowser anywhere. Here is the source of the element and I think it involves some javascript which I have no experience with.
Here is one attempt I tried. I have attempted getting the element by point but that does not seem very efficient since the form is not in the same position every time.
Other attempt
It's just a button I wanna click but it is really frustrating me cause it seems so simple. Any help would be much appreciated
HTML Code:
<div class="enterFlavor">
<p class="mediumText">This drink?</p>
<a href="javascript:;" brand-id="BC9">
<img src="http://************.com/bevprod/BC9.png" alt="Seagrams Cherry" height="140" width="90">
</a>
</div>
Code:
Dim AllElements As HtmlElementCollection = WebBrowser1.document.All
For Each indelem As HtmlElement In AllElements
If indelem.GetAttribute("className") = "enterFlavor" Then
Dim xpos As Integer = GetXOffSet(indelem)
Dim finalx As Double = xpos * 0.5
Dim ypos As Integer = GetYOffSet(indelem)
Dim finaly As Double = ypos * 0.5
Dim NewPoint As New Point(finalx, finaly)
Dim area As HtmlElement = WebBrowser1.document.GetElementFromPoint(NewPoint)
area.InvokeMember("click")
End If
Next
Code:
Dim allelements As HtmlElementCollection = WebBrowser1.document.All
For Each webpageelement As HtmlElement In allelements
If webpageelement.GetAttribute("className") = "enterFlavor" Then
If webpageelement.InnerText = "Seagrams Cherry" Then
webpageelement.InvokeMember("click")
End If
End If
Next