IE automation with javascript form image

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 5 years, 9 months ago.

  • Author
    Posts
  • #5281

    by AA2012 at 2012-11-15 08:15:48

    Hi Everyone,

    This is both my first post on PowerShell.org as well as first time using PowerShell. I'm currently trying to figure out how to automate a web login process and have hit a roadblock. I have searched the form the closest related post
    'http://powershell.org/discuss/viewtopic.php?f=2&t=592&p=2303&hilit=html+form#'p2303 Its similar issue but slightly different as the submit button for the form is a image.

    I am currently trying to automate a login via IE.
    Here is a link to the webpage: https://fiaegus.markit.com/egus/auth/login.jsp

    I can fill in the username and password fields with the following logic:

    [code2=powershell]Import-Module C:\Users\A\Desktop\WASP\WASP.dll
    $username = 'username'
    $password = 'password'
    $IEProcess = Select-Window -Title "FIA Electronic Give-Up System Login*"

    $ie = new-object -com InternetExplorer.Application
    $ie.navigate("https://fiaegus.markit.com/")
    do {sleep 1} until (-not ($ie.Busy))
    $ie.visible = $true

    $usernameField = $doc.getElementById('username')
    $usernameField.value = $username
    $passwordField = $doc.getElementById('password')
    $passwordField.value = $password

    $IEProcess | Send-Keys "{Enter}"[/code2]

    Login button is stored as a image and doesn't have element id or tag name I can use to identify the button. So I tried to use the Select-Title and then Send Keys approach but nothing happens. I suspect I need to tweak the Select Window but not sure. Has anyone encountered a similar issue? If so, any suggestions would be appreciated. I'm just spinning my wheels at this point 🙂

    by coderaven at 2012-11-16 07:58:54

    I have not looked at the page but I have done this a few times and I think you want to look for the submit function of the form that contains the username and password fields. The image button is just calling that function.

    by AA2012 at 2012-11-16 15:02:46

    You were correct. This ended up being what worked for me, $doc.getElementById('loginForm').submit().
    Thanks for your help.

You must be logged in to reply to this topic.