0

I am currently using a WebBrowser function in a c# application to automate a login and get information. The problem is when I set a textbox's value by ID, it does not work, it remains as it was (I checked by getting the console to write its value). Here is my code

br.Document.GetElementById("username").SetAttribute("Value", username);
br.Document.GetElementById("password").SetAttribute("Value", password);

br.Document.GetElementById("LoginBtn").InvokeMember("click");

//authcode
Thread.Sleep(5000);

Console.WriteLine(br.Document.GetElementById("username").InnerText) // This does not retrieve the data.

Any and all help is appreciated.

1 Answer 1

1

You are setting the Value attribute, then checking the InnerText of the tag. Assuming "username" is an input field, it won't have any inner text. You need to check the value of the Value attribute.

Console.WriteLine(br.Document.GetElementById("username").GetAttribute("Value");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.