Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > .NET Languages
You last visited: Today at 16:50

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



VB.NET Login/Submit button ID/Name

Discussion on VB.NET Login/Submit button ID/Name within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1
 
Cheating-nl's Avatar
 
elite*gold: 0
Join Date: Sep 2011
Posts: 417
Received Thanks: 237
VB.NET Login/Submit button ID/Name

Hi,

I trying to login using a webbrowser in vb.net with the following:

Code:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        WebBrowser1.Document.GetElementById("username").SetAttribute("value", TextBox1.Text)
        WebBrowser1.Document.GetElementById("password").SetAttribute("value", TextBox2.Text)

WebBrowser1.Document.GetElementById("ID_HERE").InvokeMember("click")


    End Sub
However, I can't find the ID/Name of the Submit/Login button.

Website:

Somebody able to help me out?

Thanks in advance
Cheating-nl is offline  
Old 08/09/2014, 00:13   #2

 
Terreox's Avatar
 
elite*gold: 155
Join Date: Aug 2009
Posts: 628
Received Thanks: 153
Quote:
Originally Posted by Cheating-nl View Post
However, I can't find the ID/Name of the Submit/Login button.

Website:

Somebody able to help me out?

Thanks in advance
That's because the submit button has no id assigned to it.
I don't know if you can use XPath with your Browser control but if you can then just learn some basics about XPath and get the submit button with its XPath.
If you can't use XPath then you could try to execute some piece of Javascript to get and click the submit button.
Terreox is offline  
Old 08/09/2014, 12:32   #3
 
Cheating-nl's Avatar
 
elite*gold: 0
Join Date: Sep 2011
Posts: 417
Received Thanks: 237
Hmm okey, I think I just gonna try it with webrequests then.
Should be a better alternative too.
Cheating-nl is offline  
Old 08/09/2014, 15:28   #4

 
PC Jones's Avatar
 
elite*gold: 50
The Black Market: 266/0/0
Join Date: Oct 2009
Posts: 7,096
Received Thanks: 623
If the button has a unique class-name you can do this:
Code:
            For Each element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("input")
                If element.GetAttribute("className") = "THE_CLASS_NAME" Then
                    element.invokeMember("click")
                End If
            Next
But of course, WebRequests are much better.

edit: The className seems to be bgcdw_button bgcdw_login_form_login
I've tried it and it worked
PC Jones is offline  
Thanks
1 User
Old 08/09/2014, 16:59   #5

 
Terreox's Avatar
 
elite*gold: 155
Join Date: Aug 2009
Posts: 628
Received Thanks: 153
Quote:
Originally Posted by PC Jones View Post
If the button has a unique class-name you can do this:
Code:
            For Each element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("input")
                If element.GetAttribute("className") = "THE_CLASS_NAME" Then
                    element.invokeMember("click")
                End If
            Next
But of course, WebRequests are much better.

edit: The className seems to be bgcdw_button bgcdw_login_form_login
I've tried it and it worked
You could do this but a class is not unique by nature it might work in this case but I would generally not rely on this even if a class appears to be unique.
Terreox is offline  
Old 08/09/2014, 17:54   #6
 
elite*gold: 1186
Join Date: Apr 2014
Posts: 1,717
Received Thanks: 169
Use webrequest for logins etc...


They are better & faster.
ZiD. is offline  
Old 08/10/2014, 18:04   #7
 
Cheating-nl's Avatar
 
elite*gold: 0
Join Date: Sep 2011
Posts: 417
Received Thanks: 237
Quote:
Originally Posted by PC Jones View Post
If the button has a unique class-name you can do this:
Code:
            For Each element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("input")
                If element.GetAttribute("className") = "THE_CLASS_NAME" Then
                    element.invokeMember("click")
                End If
            Next
But of course, WebRequests are much better.

edit: The className seems to be bgcdw_button bgcdw_login_form_login
I've tried it and it worked
Thanks! I'll maybe gonna use this, but first I try to use webrequests for now.

EDIT: Working with the webrequests now, can't find the right referer for Seafight login.
Found this but doesn't seem to work:

Code:
Dim postData As String = "referer=http%253A%252F%252Fwww." & NsTextBox3.Text & ".seafight.bigpoint.com%252Fusername%253D" & NsTextBox1.Text & "%2526password%253D" & NsTextBox2.Text
NsTextbox1.Text contains the Username
NsTextbox2.Text contains the Password
NsTextbox3.Text contains the server shortcut (ex. int1)
Cheating-nl is offline  
Old 08/11/2014, 07:14   #8


 
elite*gold: 1091
Join Date: Jun 2007
Posts: 19,836
Received Thanks: 7,180
What do you mean by "referer"? The HTTP header?

Did you perform a GET request before posting your data to the website? There might have been some cookies you've missed.
Mostey is offline  
Old 08/11/2014, 13:17   #9
 
Cheating-nl's Avatar
 
elite*gold: 0
Join Date: Sep 2011
Posts: 417
Received Thanks: 237
Yes, I mean the HTTP header.

The code I have so far:

Code:
Dim logincookie As CookieContainer

    Private Sub NsButton1_Click(sender As Object, e As EventArgs) Handles NsButton1.Click

        Dim postData As String = "referer=http%253A%252F%252Fwww." & NsTextBox3.Text & ".seafight.bigpoint.com%252Fusername%253D" & NsTextBox1.Text & "%2526password%253D" & NsTextBox2.Text
        Dim tempCookies As New CookieContainer
        Dim encoding As New UTF8Encoding
        Dim byteData As Byte() = encoding.GetBytes(postData)

        Dim postReq As HttpWebRequest = DirectCast(WebRequest.Create("http://" & NsTextBox3.Text & ".seafight.bigpoint.com/index.es?action=internalHome&loginDone=true"), HttpWebRequest)
        postReq.Method = "POST"
        postReq.KeepAlive = True
        postReq.CookieContainer = tempCookies
        postReq.ContentType = "application/x-www.form.urlencoded"
        postReq.Referer = "http://" & NsTextBox3.Text & ".seafight.bigpoint.com/index.es?action=internalHome&loginDone=true"
        postReq.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/4.0 (.NET CLR 3.5.30729)"
        postReq.ContentLength = byteData.Length

        Dim postreqstream As Stream = postReq.GetRequestStream()
        postreqstream.Write(byteData, 0, byteData.Length)
        postreqstream.Close()
        Dim postresponse As HttpWebResponse

        postresponse = DirectCast(postReq.GetResponse(), HttpWebResponse)
        tempCookies.Add(postresponse.Cookies)
        logincookie = tempCookies
        Dim postreqreader As New StreamReader(postresponse.GetResponseStream())

        Dim thepage As String = postreqreader.ReadToEnd

        RichTextBox1.Text = thepage

    End Sub
However, It seems the HTTP header isn't the right one and I can't seem to find the right one with LiveHTTPHeader or Fiddler, any tips to find the right one?

My current HTTP header =
Code:
"referer=http%253A%252F%252Fwww." & NsTextBox3.Text & ".seafight.bigpoint.com%252Fusername%253D" & NsTextBox1.Text & "%2526password%253D" & NsTextBox2.Text
Or maybe a good tutorial with good explanation.

Thanks in advance.
Cheating-nl is offline  
Reply


Similar Threads Similar Threads
[Question]Disable Confirm Button and Enable Submit
11/14/2014 - Shaiya PServer Development - 14 Replies
Hello everyone today i come to you all to let you know that i have successfully enabled the 'OK' Button when attempting to do a transaction on a game.exe ep 5.4 - 6 . It took me days and maybe even a week to figure this out LOL. But i would like to get the opinions of the REAL FEW developers and coders of this community. Would it be something you guys would like me to do a tutorial about it or just simply give address and things to change on those addresses?. Or maybe would it b something that...
Homepage Submit Button!
04/29/2012 - Flyff Private Server - 3 Replies
Guten Tag, ich wollte mal Fragen ob es so funktionieren kann wie ich es umgeschrieben habe. Es geht um ein weiteres Donate Script wo ich halt mit dem PayPal donate Button es absenden kann. Hier ist es vom Paysafe: <input type="submit" name="psc_sbm" value="Donate Now" /> Und so habe ich es im Paypal Script geschrieben: <form action="https://www.paypal.com/cgi-bin/webscr " method="post">
PHP: Submit Button und Eintrag in Log
04/16/2012 - Web Development - 3 Replies
Hallo, wie kann ich nach einem Klick auf einen Submit-Button gleichzeitig einen Eintrag in einer .txt Datei machen, mit dem Inhalt der Variablen $settings, $userdata und $userdata?
Mein Script soll den Submit Button drücken
11/27/2011 - AutoIt - 8 Replies
Hallo Jungs, habe seit längerem ein Script vor, das ich gestern endlich richtig angefangen habe. Es soll mir auf einer Webseite automatisch Gästebucheinträge schreiben. Habe es selber soweit geschafft, dass er eine Seite aufmacht und ins Gästebuch schreibt. Leider schaff ich es nicht, dass er es abschickt bzw. den Submit Button drückt. Habe gestern Nacht alles probiert, bis ich wirklich Kopfschmerzen bekommen habe. Über Hilfe wäre ich sehr dankbar, am besten mit TS3 oder so, da ich die...
2 Submit Button ein Problem
03/17/2011 - AutoIt - 2 Replies
Hallo AutoItler, ich möchte den Submit Button name="start" anklicken weiß aber nich wie ich das machen soll habs schon mit _IEFormSubmit() und _IEAction() probiert aber es funktioniert nicht. Und hier der Quelltext: Ich möchte den Submit Button name="start" anklicken. <form name='arena' id='arena' action='/bg/arena.php' method='post'> <input type='hidden' name='__token' value='57c6bb5cdb0a6782a9bc18362cc67402' /> <input type="submit" name="start" value="Kampf starten" /><br /><br /> ...



All times are GMT +1. The time now is 16:51.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.