title: Powershell access HTML frames
body: <p>I've been trying to create a powershell script to automate something in my router's website but I can't really navigate through the sites frames and framesets, any help would be greatly appreciated!</p>
  
  <pre class="lang-bsh prettyprint-override"><code>$ie = New-Object -ComObject 'internetExplorer.Application'
  $ie.Visible= $true # Make it visible
  $ie.Navigate("http://192.168.1.1")
  While ($ie.Busy -eq $true) {Start-Sleep -Seconds 3;}
  $usernamefield = $ie.document.getElementByID('userName')
  $usernamefield.value = "admin"
  $passwordfield = $ie.document.getElementByID('pcPassword')
  $passwordfield.value = "admin"
  $Link = $ie.document.getElementByID('loginBtn')
  $Link.click()
  $Frame1a = $ie.document.getElementByID("topFrame") 
  $Frame2a = $Frame1a.contentWindow
  $Frame3a = $Frame2a.document
  $Frame1b = $Frame3a.getElementByID('bottomLeftFrame')
  $Frame2b = $Frame1b.contentWindow
  $Frame3b = $Frame2b.document
  $thing = $Frame3b.getElementsByTagName('a') | where-object {$_.innerText -eq 'Wireless'}
  </code></pre>
  
  <p>This is the code I have so far, but when it gets to <code>$Frame1b = $Frame3a.getElementByID('bottomLeftFrame')</code> I get an error message saying: "You cannot call a method on a null-valued expression."</p>
  
  <p>After I get this frame thing to work, I'd need it to click a hyperlink, if anyone knows how to do that please tell me, I've tried before but it didn't work. I've also tried different languages before, python, VBS, but I got the furthest with powershell.</p>
  
  <p>Thanks for the attention!</p>