3mustgetbeers Posted December 23, 2015 Share Posted December 23, 2015 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 :SThanks in advance for any replies & help - and merry Christmas!3MGB Link to comment Share on other sites More sharing options...
Danyfirex Posted December 23, 2015 Share Posted December 23, 2015 For me it works well. it sets user and password correctly. Saludos 3mustgetbeers 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
3mustgetbeers Posted December 23, 2015 Author Share Posted December 23, 2015 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, IE9More importantly, any idea why it wouldn't work for me Link to comment Share on other sites More sharing options...
Danyfirex Posted December 23, 2015 Share Posted December 23, 2015 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 3mustgetbeers 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
3mustgetbeers Posted December 23, 2015 Author Share Posted December 23, 2015 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 Link to comment Share on other sites More sharing options...
Danyfirex Posted December 23, 2015 Share Posted December 23, 2015 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 3mustgetbeers 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
3mustgetbeers Posted December 24, 2015 Author Share Posted December 24, 2015 DanyfirexMate, that works a treat! Thank you very much :o)3MGB Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now