Click here to Skip to main content
15,886,563 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
Hi guys,,

i would not ask this but its been driving me crazy now for 6 hours and i cant figure out how to click this button,,

trust me,, ive tried 50 different things,, any help would be great-full

here is the html, i am simply trying to click the Follow
<div class="profile-actions">
        <form action="/BaltimoreBama/follow" method="post">
          <div style="margin:0;padding:0;display:inline"><input name="authenticity_token" type="hidden" value="a15a8f386c94dc625fd6" /></div>
          
          <span class="w-button-common w-button"><input name="commit" type="submit" value="Follow" /></span>
        </form>
        <form action="/BaltimoreBama/favorites" method="get">
          <span class="w-button-common w-button"><input name="commit" type="submit" value="View favs" /></span>
        </form>
          <form action="/BaltimoreBama/block" method="post">
            <div style="margin:0;padding:0;display:inline"><input name="authenticity_token" type="hidden" value="a15a8f386c94dc625fd6" /></div>
            
            <span class="w-button-common w-button"><input name="commit" type="submit" value="Block" /></span>
          </form>
</div>
  </div>


Thinks i have tried,, too many to list but here are a couple

If WebBrowser12.Document.DomDocument.All("value").Value = ("Follow") Then

           WebBrowser12.Document.DomDocument.All.Focus()
           WebBrowser12.Document.DomDocument.All.InvokeMember("click")
       Else

       End If


and

Dim ii As Integer
       Dim allButtonsi As HtmlElementCollection

       allButtonsi = WebBrowser12.Document.GetElementsByTagName("input")
       'screen_names[]
       ii = 0
       Try
           For Each webpageelement As HtmlElement In allButtonsi
               Dim NameStr As String = webpageelement.GetAttribute("value")
               If NameStr.ToLower().Equals("Follow") Then
                   ii += 1
                   If ii = 1 Then
                       webpageelement.Focus()
                       webpageelement.InvokeMember("click")
                   End If
               End If

           Next
       Catch
       End Try
Posted
Updated 25-Sep-12 7:32am
v2

K,, well,, i found a work around for the follow button on twitter,

all you do is place /follow after the persons name, hence,, if you were to follow
oprah,, then this would be the link to go to

https://mobile.twitter.com/oprah/follow

then here is the code to click the follow button that has worked,, FINALLY,, LOL

Try
           WebBrowser12.Document.DomDocument.All("commit").Click()
           Do Until WebBrowser12.ReadyState = System.Windows.Forms.WebBrowserReadyState.Complete
               System.Windows.Forms.Application.DoEvents()
               ' wait(1000)
               ' Delay(1)
           Loop
       Catch
       End Try
 
Share this answer
 
AmolPandurangBorkar,

i tried both of these with the id attribute as you said and they did not work,, any other ideas,, im willing to try anything at this point,,

Dim ii As Integer
       Dim allButtonsi As HtmlElementCollection

       allButtonsi = WebBrowser12.Document.GetElementsByTagName("input")
       'screen_names[]
       ii = 0
       Try
           For Each webpageelement As HtmlElement In allButtonsi
               Dim NameStr As String = webpageelement.GetAttribute("value")
               If NameStr.ToLower().Equals("a15a8f386c94dc625fd6") Then
                   ii += 1
                   If ii = 1 Then
                       webpageelement.Focus()
                       webpageelement.InvokeMember("click")
                   End If
               End If

           Next
       Catch
       End Try


and


If WebBrowser12.Document.DomDocument.All("value").Value = ("a15a8f386c94dc625fd6") Then

           WebBrowser12.Document.DomDocument.All.Focus()
           WebBrowser12.Document.DomDocument.All.InvokeMember("click")
       Else

       End If
 
Share this answer
 
Try putting id attribute for the input button like:



 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900