11

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

Avshalom
  • 8,657
  • 1
  • 25
  • 43
  • You can use WASP for PowerShell [link](https://wasp.codeplex.com) . Import the module. Once on a page close to where you need to go you could use $IE | Send-Keys "{TAB}" a set amount of times to navigate through the webpage to get where you want. – Shaun Webb Oct 24 '15 at 18:22
  • wasp is not an option, should be run on multiple systems, WShell.SendKey is not an option as wel, not stable at all – Avshalom Oct 24 '15 at 20:30

3 Answers3

1

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") 
Community
  • 1
  • 1
Loïc MICHEL
  • 24,935
  • 9
  • 74
  • 103
0

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.

Ravi Kanth
  • 1,182
  • 13
  • 38
  • U just once go through the Following Links for Getting Brief idea : UI Path: [http://www.uipath.com/]
    UI Automation: [https://msdn.microsoft.com/en-us/library/ms747327(v=vs.110).aspx] White :[https://github.com/TestStack/White] Watin: [http://watin.org/]
    – Ravi Kanth Oct 30 '15 at 04:38
0

OK I found it :)

The problem was that the site has 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

Avshalom
  • 8,657
  • 1
  • 25
  • 43