htmlinternet-explorerpowershellautomationcomobject

Automate (IE ComObject) Fill Textboxes


I'm Trying to Automate a Outlook Web Access website, fill some textboxes and click a buttons,

I can find the relevant elements in the first page(sign-in) and the submit button, so i pass the login phase, my problem is to find the elements inside some page with masked textboxes, i attached a snapshots of the 3 steps, and also the DOM image of the object.

The Login Page

$IE = New-Object -ComObject InternetExplorer.Application
$URL = 'https://somewebsite/ecp/?rfr=owa&p=PersonalSettings/Password.aspx'
$IE.Visible = $true
$IE.Navigate($URL)
While ($IE.Busy -eq $true) {Start-Sleep -Milliseconds 2000} 

$ie.Document.getElementById('username').value = "username"
$ie.Document.getElementById('password').value = "password"
$Submit = $ie.Document.getElementsByTagName('Input') | ? {$_.Type -eq "Submit"}
$Submit.click()

so far so good, my problem start in the pages inside, i just can't find the textboxes elements for the password fields,

enter image description here

also here's the DOM snapshot for those elements:

enter image description here

I'm really appreciate any help


Solution

  • I had the same sort of problem when trying to automate a file upload on sharepoint . The trick was that the upload form was open inside a new frame.

    <iframe id="Dlg..." class="ms-dlgFrame" src="https://.../Upload.aspx?List=..."></iframe>
    

    So to get the input fields I had to look into each open frames and select the one with the good location :

    for($i=0;$i -lt $ie.Document.frames.length;$i++){
       if( $ie.Document.frames.item($i).location.href -match 'upload.aspx' ){
           $frm=$ie.Document.frames.item($i)}
     }
    

    from then I was able to target the input field:

    $frm.document.body.getElementById("txtOldPwd")