title: Delphi Twebbrowser Identify html element id
body: <p>All, we have an RFID application that is web based.  We are trying to make display boards across our facility that shows information.  I'm trying to make the webpage auto-login but I'm not having any luck.  I've tried enumerating all tags/elements on the page but I'm not having any luck.</p>
  
  <p>Access violation with the line below (because the element j_username isn't found, but it's clearly in the html snippet.  I know I'm missing something simple. Can someone please help?</p>
  
  <pre><code> WebBrowser1.OleObject.Document.GetElementByID('j_username').
       setAttribute('value', 'dempseyw');
  </code></pre>
  
  <p>here is the login code from the page I am trying to automate.</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;head&gt;
  &lt;meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /&gt;
  &lt;meta http-equiv="Pragma" content="no-cache" /&gt;
  &lt;meta http-equiv="Expires" content="0" /&gt;
          &lt;title&gt;MobileView&lt;/title&gt;
          &lt;style type="text/css"&gt;
                      .loginTextCss{
                               padding:0 0 0 22;
                      }
  
  
              #javax_faces_developmentstage_messages{
                  display: none;
              }
          &lt;/style&gt;&lt;/head&gt;&lt;body onload="document.getElementById('j_username').focus()" style="margin:0px; overflow: hidden;"&gt;
      &lt;div style="display:none" id="notLogedInMarker"&gt;&lt;/div&gt;
      &lt;form action="http://dmh-rfidweb/asset-manager-web/j_spring_security_check" method="post"&gt;
          &lt;table border="0" align="center" height="100%" width="687" cellpadding="0" cellspacing="0"&gt;
          &lt;tr&gt;
              &lt;td height="50%" valign="top"&gt;
                  &lt;img src="http://dmh-rfidweb/asset-manager-web/images/spacer.gif" border="0" width="1" height="1" /&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
  
          &lt;tr&gt;
              &lt;td class="directionCss"&gt;&lt;span style="font-size:12px; font-weight: bold; color: #0000FF; font-family:arial"&gt;&lt;/span&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
  
  
          &lt;tr&gt;
              &lt;td height="427" valign="top" background="http://dmh-rfidweb/asset-manager-web/images/branding/healthcare/bg_login.jpg" style="background-repeat:no-repeat; color:#000000; font-family:arial, Helvetica, sans-serif; font-size:14px;"&gt;
                  &lt;div style="width:200px;height:150px;float:right;"&gt;
                      &lt;table border="0" width="100%" cellpadding="0" cellspacing="0"&gt;
  
                      &lt;tr&gt;
                          &lt;td style="padding:3 6 0 22;" valign="bottom"&gt;
                              &lt;br clear="all" /&gt;
                              &lt;a href="https://www.stanleyhealthcare.com/" target="new"&gt;&lt;img src="http://dmh-rfidweb/asset-manager-web/images/branding/healthcare/logo_mobileview.gif" style="border:1; hspace:2;" /&gt;
                              &lt;/a&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;/table&gt;
                  &lt;/div&gt;
                  &lt;br clear="all" /&gt;
  
                  &lt;div style="height:50; padding:0 0 0 15;"&gt;
                      &lt;div style="height:10;"&gt;&lt;/div&gt;
                  &lt;/div&gt;
  
                  &lt;div class="loginTextCss"&gt;&lt;label for="j_username"&gt;User Name:&lt;/label&gt;
                      &lt;br /&gt;&lt;input id="j_username" name="j_username" type="text" value="" style="font-size:16px; width:170px;" /&gt;
                      &lt;br /&gt;
                      &lt;br /&gt;&lt;label for="j_password"&gt;Password:&lt;/label&gt;
                      &lt;br /&gt;&lt;input type="password" id="j_password" name="j_password" value="" style="font-size:16px; width:170px;" /&gt;
                      &lt;br /&gt;
                          &lt;div style="font-size:11;"&gt;
                              &lt;input id="rememberMe" type="checkbox" name="_spring_security_remember_me" title="Remember me on this computer" checked="Checked" /&gt;
                              &lt;label for="rememberMe" title="Remember me on this computer"&gt;Remember me on this computer&lt;/label&gt;
                          &lt;/div&gt;
  
                      &lt;div style="padding-left:112px;padding-top:20;"&gt;
                          &lt;input type="submit" value="Log In" style="padding:3 10 3 10;color:#000000; font-family:arial, Helvetica, sans-serif;font-size:14px;" /&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
  
          &lt;tr&gt;
              &lt;td height="50%" valign="top"&gt;
                  &lt;img src="http://dmh-rfidweb/asset-manager-web/images/spacer.gif" border="0" width="1" height="1" /&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
  
          &lt;/table&gt;
      &lt;/form&gt;&lt;/body&gt;
  &lt;/html&gt;
  </code></pre>