Jump to content

IE Form - Submit button not activated


qontro1
 Share

Recommended Posts

Hi,

I am trying to automate authentication to this web application, and whilst the fields are populated using the below script, it does not seem to activate the submit button, that is, it CAN'T be pressed. I have tried using IEActions such as click/focus prior to input, doesn't seem to work. I need to enter a character manually into each field before it is activated. Any suggestions appreciated.

 

Thank you.

 

Code and form below.

 

#include <IE.au3>
Global Const $exe                                    = "C:\Program Files (x86)\Internet Explorer\iexplore.exe https://10.0.0.1" 
Global Const $un = "abcdefg"
Global Const $pw = "1234567"
Run($exe)
WinWait("Title - Internet Explorer")
WinActive("Title - Internet Explorer")
Sleep(2000)
Local $oIE = _IEAttach("","instance",1)
Local $oForm = _IEFormGetCollection($oIE, 0)
Local $unfield = _IEFormElementGetCollection($oForm, 0)
Local $pwfield = _IEFormElementGetCollection($oForm, 1)
Local $oSubmit = _IEFormElementGetCollection($oForm, 2)
_IEFormElementSetValue($unfield, $un)
_IEFormElementSetValue($pwfield, $pw)
_IEAction($oSubmit,"click")
 

 

<form data-bind="submit: login, visible: !pvm.loggingIn()" role="form" lpformnum="1">
      <div class="form-group">
        <label>Username</label><input class="form-control" data-bind="textInput: username" placeholder="enter your username" type="text" style="background-image: url(&quot;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAAAAXNSR0IArs4c6QAAAPhJREFUOBHlU70KgzAQPlMhEvoQTg6OPoOjT+JWOnRqkUKHgqWP4OQbOPokTk6OTkVULNSLVc62oJmbIdzd95NcuGjX2/3YVI/Ts+t0WLE2ut5xsQ0O+90F6UxFjAI8qNcEGONia08e6MNONYwCS7EQAizLmtGUDEzTBNd1fxsYhjEBnHPQNG3KKTYV34F8ec/zwHEciOMYyrIE3/ehKAqIoggo9inGXKmFXwbyBkmSQJqmUNe15IRhCG3byphitm1/eUzDM4qR0TTNjEixGdAnSi3keS5vSk2UDKqqgizLqB4YzvassiKhGtZ/jDMtLOnHz7TE+yf8BaDZXA509yeBAAAAAElFTkSuQmCC&quot;); background-repeat: no-repeat; background-attachment: scroll; background-size: 16px 18px; background-position: 98% 50%; cursor: auto;" autocomplete="off">
      </div>
      <div class="form-group">
        <label>Password</label><input class="form-control" data-bind="textInput: password" type="password" style="background-image: url(&quot;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAAAAXNSR0IArs4c6QAAAPhJREFUOBHlU70KgzAQPlMhEvoQTg6OPoOjT+JWOnRqkUKHgqWP4OQbOPokTk6OTkVULNSLVc62oJmbIdzd95NcuGjX2/3YVI/Ts+t0WLE2ut5xsQ0O+90F6UxFjAI8qNcEGONia08e6MNONYwCS7EQAizLmtGUDEzTBNd1fxsYhjEBnHPQNG3KKTYV34F8ec/zwHEciOMYyrIE3/ehKAqIoggo9inGXKmFXwbyBkmSQJqmUNe15IRhCG3byphitm1/eUzDM4qR0TTNjEixGdAnSi3keS5vSk2UDKqqgizLqB4YzvassiKhGtZ/jDMtLOnHz7TE+yf8BaDZXA509yeBAAAAAElFTkSuQmCC&quot;); background-repeat: no-repeat; background-attachment: scroll; background-size: 16px 18px; background-position: 98% 50%; cursor: auto;" autocomplete="off">
      </div>
      <button class="btn btn-default" data-bind="enable: enableLoginButton" type="submit" disabled="">Log In</button>
    </form>

Link to comment
Share on other sites

  • 4 years later...

Guys, did this get resolved?  I bumped to the same problem.

Got an embedded IE in an app with a login form I need to automate. The form has no name or ID, but I can fill in the fields using this method:

$formLogin = _IEGetObjById ($oIE, "usernameField")
$formLogin.value = "Tester"

Also tried this method to fill in the form with the same result
 

_IEFormElementSetValue($formLogin, "Tester")

 

But even I do that, the login button will not activate.  I checked the source of the HTML and it has indeed a Javascript taking care of the button:

function updateLoginButton() {
        var loginButton = document.getElementById('loginButton');
        var username = document.getElementById('usernameField').value;
        var password = document.getElementById('passwordField').value;

        loginButton.disabled = !(username.length > 0 && password.length > 0);
    }

The only test it does is the username and password length, but no onevent or on change or onkeydown i could find, 

I tried to include 

$formLogin.fireEvent("onKeydown")

trying multiple "onchange" "onkyeup" on both fields, with no luck, to get the button activated I need to click in the filed and type in any of the 2 fields 1 stroke and then the button activates.

I could physically click to the fields and send the keystrokes, but I do not want to bring the app forward and rely on the position of the app. I'm not able to address the fields in other methods than described above.

Any ideas or direction would be appreciated. I tried to search for it. But either not good at searching or people don't post their solutions.

 

Edited by snooffy
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...