I want to fill out a loginwebpage from a webbrowser in WindowsForms. This is my code som far:
public Form1()
{
InitializeComponent();
webBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser_DocumentCompleted);
webBrowser.Navigate("https://www.loginpage.com");
}
private void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
// Check if the document is fully loaded
if (webBrowser.ReadyState == WebBrowserReadyState.Complete)
{
HtmlElement inputElement = webBrowser.Document.GetElementById("passwordField");
// Set the attribute, for example, change the value attribute
if (inputElement != null)
{
inputElement.SetAttribute("Value", "New Value");
}
}
}
I cant fill out the element. I checked and the webpage is laoded completely and i can get attributes inside the webBrowser_DocumentCompleted-function but i cant set attributes.