In general, the Internet rejected, the initial task was: to create a Windows form in which a certain site will be loaded and to autologize, did not work. Made a login using the button , says that the login and password is not correct. Checked in the explorer, all the data fit.

I spread the body of the program, if anyone knows how, lay out 2 examples - one by the second login - automatically after the page loads.

here is my code.

 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication3 { public partial class Form1 : Form { WebBrowser web = new WebBrowser(); public Form1() { InitializeComponent(); web.Navigate(""); button1.Enabled = false; } private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { button1.Enabled = true; } private void button1_Click(object sender, EventArgs e) { foreach (HtmlElement html in web.Document.GetElementsByTagName("input")) { if (html.GetAttribute("name") == "userid") { html.SetAttribute("value", "AP34593969"); } if (html.GetAttribute("name") == "password") { html.SetAttribute("value", "mazdacx77"); } web.Document.GetElementById("btsubmit").InvokeMember("click"); } } } } 

    1 answer 1

    Try to render web.Document.GetElementById("btsubmit").InvokeMember("click"); for the body of the cycle.

    • Use slanted quotes to format the line of the code: ` rather than ' . - AivanF.