Automate (IE ComObject) Fill Textboxes Automate (IE ComObject) Fill Textboxes powershell powershell

Automate (IE ComObject) Fill Textboxes


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") 


It's possible with Using UI Automation.there we can easily detect the element using the Automation ID and we can easily perform Read/Write operation's.But i don't know whether your are comfortable using UI automation,if its fine then i think i can help you out.there are many opetion in UI automation such as

1)UI automation.

2)White

3)watin.etc.,

if you are comfortable with any of the framework then i think i can help you out.


OK I found it :)

The problem was that the site had a two iframe tags, one inside the other,

$IFrame = $ie.Document.getElementsByTagName('iframe').item(0)$IFrame = $IFrame.contentWindow.document.getElementsByTagName('iframe').item(0)$PasswordSlab = $IFrame.contentWindow.document.getElementById('passwordSlab')$PasswordSlab.document.getElementById('txtOldPwd').value = $OldPassword$PasswordSlab.document.getElementById('txtNewPwd').value = $NewPassword$PasswordSlab.document.getElementById('txtConfirmPwd').value = $NewPassword$PasswordSlab.document.getElementById('save').click()

Thanks for everybody