title: WebBrowser SetAttribute not setting value on password input element
body: <p>I have an application that uses WebBrowser control to go to a website, and try to log in. I found a few questions that seem similar but are not the same, and their answers do not help.</p>
  
  <p>The website prompts for the information in steps, first prompts  for the username, then prompts for the challenge question, then prompts for the password. To debug, I've created three buttons, one for each step above, so that I can separate to see what works and what doesn't. (In the end this will be fully automated, without any user interaction).</p>
  
  <p>The first button navigates to the site and enters the username and submits -- that works fine. The second button is supposed to enter the answer to the challenge question, but the site returns saying that the entry is invalid. The actual HTML looks like this:</p>
  
  <pre><code>&lt;input name="IDToken1" tabindex="1" id="IDToken1" style="padding: 2px; border: 2px solid rgb(240, 0, 0); border-image: none; width: 226px; color: black;" type="password" size="40" maxlength="40" value="" autocomplete="off"&gt;
  </code></pre>
  
  <p>The code to enter the challenge question looks like this:</p>
  
  <pre><code>        var browser = (WebBrowser)_interactor.WinForm.Controls["browser"];
          var txt = browser.Document.GetElementById("IDToken1");
          if (txt != null)
          {
              txt.SetAttribute("Value", "answer-to-question");
  
              // set event handler on click
              //btnContinue.AttachEventHandler("onclick", (sender, args) =&gt; OnElementClicked(txt2, EventArgs.Empty));
  
              var btnLogin = browser.Document.GetElementById("signIn");
              btnLogin.InvokeMember("click");
          }
  </code></pre>
  
  <p>I verified that the value is properly set by adding an event handler to the submit button, then checking the input value at the point of the form submission. The value looks to be set at that point, but when the form is submitted it returns an error, stating that the value is not valid. </p>
  
  <p>I've also tried entering it by submitting the actual form, like so:</p>
  
  <pre><code>        browser.Document.Forms["challengequestion"].Children["IDToken1"].SetAttribute("Value", "answer-to-question");
          browser.Document.Forms["challengequestion"].InvokeMember("submit");
  </code></pre>
  
  <p>I get the same response. </p>
  
  <p>I've also tried doing the cache clear as suggested <a href="https://stackoverflow.com/questions/1608543/webbrowser-control-caching-issue">here</a>, which does not seem to help.</p>
  
  <p>Finally, I've tried manually entering the answer and clicking the submit button, via the WebBrowser control on the application.</p>
  
  <p>What am I missing? If I check the value of the input element on form submit and it has the proper value, how is it that the site is not able to see it? I enter the same value manually on the control and it works fine. Any ideas?</p>