3mustgetbeers

_IEGetObjById - Not returning value

7 posts in this topic

Good evening.

I am frustratingly being foiled by a simple web login script.  The username and button click work fine, but obtaining the password field is for some reason not working (probably because I have the incorrect value!).  I have tries substituting the _IEGetObjById with _IEGetObjByName, however both fail.  I know it is not getting the field name as opposed to not writing to it due to the MsgBox contents.  Can anyone advise what I a doing wrong - i.e. if both usrnm & psswd were not being written to it would be obvious, but the fact that it finds one and not the other is baffling me.  Here is my code:

 

#include<IE.au3>

$IE       =_IECreate("https://my.ovoenergy.com/login")
$Username = "Some_Username"
$Password = "Some_Password"
$Username_Field = _IEGetObjById($IE,"username")
$Password_Field = _IEGetObjById($IE,"password")
$Login_Button   = _IEGetObjById($IE, "enter")


;Open Browser and wait until Browser loaded
_IELoadWait($IE)


msgbox(0,"By ID Username:",$IE.document.getElementById('username').value)
msgbox(0,"By ID Password:",$IE.document.getElementById('password').value)


;Set Inputs
sleep(2500)
_IEFormElementSetValue($Username_Field,$Username)
sleep(2500)
_IEFormElementSetValue($Password_Field,$Password)
sleep(2500)
_IEAction ($Login_Button, "click")

 

I will be looking to ditch the sleep commands as well as the MsgBox when working, these are just me testing/debugging my work.

In terms of the element; here is the Username:

<input class="form-control ng-pristine ng-scope ng-invalid ng-invalid-required ng-touched" id="username" name="username" placeholder="Email Address or Customer ID" ng-model="data.username" required="">

 

And here is the password:

<input class="form-control ng-pristine ng-scope ng-invalid ng-invalid-required ng-touched" id="password" name="password" placeholder="Password" ng-model="data.password" required="" type="password">

 

Any help is much appreciated :S

Thanks in advance for any replies & help - and merry Christmas!

3MGB

Share this post


Link to post
Share on other sites



For me it works well. it sets user and password correctly.

 

Saludos

1 person likes this

Share this post


Link to post
Share on other sites

Danyfirex - thanks for the reply & trying it out!  And really!? I am not sure if this is good news or bad news haha!

Do you mind me asking your OS & IE version?  I am Win7SP1, IE9

More importantly, any idea why it wouldn't work for me :blink:

Share this post


Link to post
Share on other sites

Does this script return you the pwd and user fields?

 

#include<IE.au3>

$IE       =_IECreate("https://my.ovoenergy.com/login")
$Username = "Some_Username"
$Password = "Some_Password"
$Username_Field = _IEGetObjById($IE,"username")
$Password_Field = _IEGetObjById($IE,"password")
$Login_Button   = _IEGetObjById($IE, "enter")


;Open Browser and wait until Browser loaded
_IELoadWait($IE)


;~ msgbox(0,"By ID Username:",$IE.document.getElementById('username').value)
;~ msgbox(0,"By ID Password:",$IE.document.getElementById('password').value)


;Set Inputs
;~ sleep(2500)
_IEFormElementSetValue($Username_Field,$Username)
;~ sleep(2500)
_IEFormElementSetValue($Password_Field,$Password)
;~ sleep(2500)

msgbox(0,"By ID Username:",$IE.document.getElementById('username').value)
msgbox(0,"By ID Password:",$IE.document.getElementById('password').value)

Saludos

1 person likes this

Share this post


Link to post
Share on other sites

Ok,

Rebooted, no different.

Upgraded to IE11; my original script msgbox now both return null values; previously it returned "Email or Customer ID" for username (the place holder) and null for password.  BUT, the script moves on and the 2 fields are now populated. 

If I try your version, the msgbox are as expected (i.e. Some_Username & Some_Password".)   So editing the field means it reads both.

But... when I change the script so that the U & P variables have the correct values, it tries to log me in but says a username & password are required.  They show in the field, I can click into each field, type a single character at the end of what the script inputs and then backspace out that single character and click "Log in" and it works fine!  So the credentials in the script are right, but the page seems to think the field is empty!?

So a step further (all 3 inputs work) but not sure why the page won't accept the values the script inputs :(

Share this post


Link to post
Share on other sites

it seems like page requiere some input event.

try this way:

_IEAction($Username_Field,"focus")
Send($Username)

Or 

_IEAction($Username_Field,"focus")
Send("aa") ;just a dummyvalue
_IEFormElementSetValue($Username_Field,$Username)

Saludos

1 person likes this

Share this post


Link to post
Share on other sites

Danyfirex

Mate, that works a treat!  Thank you very much :o)

3MGB

Share this post


Link to post
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