title: Login website --> give credentials like key press from console
body: <p>I am testing a web page, and want to make a script to login in the website automatically.</p>
  
  <p>My script goes as follows:</p>
  
  <pre><code>$username = 'username'
  $password = 'password'
  
  $ie = New-Object -ComObject 'InternetExplorer.Application'
  $ie.Visible = $true
  $ie.Navigate("url")
  
  while ($ie.Busy -eq $true) { Start-Sleep -seconds 1; }
  
  $usernamefield = $ie.Document.GetElementsByTagName("input")[0]
  $usernamefield.value = $username
  
  $passwordfield = $ie.Document.GetElementsByTagName("input")[1]
  $passwordfield.value = $password
  
  $Link = $ie.Document.GetElementsByTagName("input") |
          Where-Object {$_.Type -eq "button"}
  $Link.Click()
  </code></pre>
  
  <p>I have to search the tag names that way because the id is randomized on each time.</p>
  
  <p>My problem here is that I can not click on the Login button, because somehow the website expects credentials to be passed like a key press (I manage to complete the credential fields, but the page does not recognize it, as if they were empty). How can I achieve this, or where can I learn doing it?</p>