Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I want to enter the username and password in a website programmatically. I tried my self by some code. could not get success. I have done a lot of googling but could not get proper answer. Anybody who knows this, please help me.

What I have tried:

private void button1_Click(object sender, EventArgs e)
        {

            webBrowser1.Navigate(webBrowser1.Url);
            while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
            {
                Application.DoEvents();
            }
            webBrowser1.Document.GetElementById("username").InnerText=textBox1.Text;
            webBrowser1.Document.GetElementById("password").InnerText = textBox2.Text;
            webBrowser1.Document.GetElementById("submit").InvokeMember("LOGIN");
              
        }
Posted
Updated 14-Apr-22 17:23pm
Comments
Richard MacCutchan 15-Apr-22 5:13am    
You cannot guarantee that every website will use those exact id values.

1 solution

View the page source to get the correct elements.
 
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