Jump to content

Form elements set correctly but not submitting


 Share

Recommended Posts

Hello,

First off, hello (again?)! I've known about AutoIt for some time now but I've finally found a really good reason to get involved with it. :)

I'm currently working on a script that automatically launches a page, enters the credentials, and clicks the sign in button. I've gotten the script to work with focusing the fields and using Send() but I found that it didn't work 100% of the time and since I'm generating this for users in order to alleviate issues I'd really like to avoid that. I have gotten it to set the variables correctly and it lists them correctly in my MsgBox but no matter what I do the click seems to fail. I'm not sure if it's the way the watermark is working or some javascript behind the scenes. Any help would be much appreciated. :)

#include <IE.au3>
_IEErrorHandlerRegister()

$oIE = _IECreate("https://www.employflorida.com/vosnet/Default.aspx", 1, 1, 1, 1)
_IELoadWait($oIE)
$oForm = _IEFormGetObjByName($oIE, "aspnetForm")
$u_oObject = _IEFormElementGetObjByName($oForm, "ctl00$txtUsername")
_IEFormElementSetValue($u_oObject, "username")
$p_oObject = _IEFormElementGetObjByName($oForm, "ctl00$txtPassword")
_IEFormElementSetValue($p_oObject, "password")

MsgBox(0, "", "Username: " & _IEFormElementGetValue($u_oObject) & @CRLF & "Password: " & _IEFormElementGetValue($p_oObject))
$go_submit = _IEGetObjByID($oIE, "ctl00_cmdLogin")
_IEAction($go_submit, "click")
Edited by azurekite
Link to comment
Share on other sites

Hmm, it seems like that would have been important but it still won't submit. It seems like some javascript is preventing it because it doesn't actually enter information into the field. Is there an alternative way to physically enter things into the field that could be used without _IEAction("", "focus") and Send()?

Link to comment
Share on other sites

Digging into it a little more, I'm sure now that my problems are stemming from this chunk of code.

function conditionScript() {
   if ($('#txtUsername').val() == '' || $('#txtUsername').val() == 'Username' || $('#txtPassword').val() == 'Password') {
       return false;
   }
   else {
       return true;
   }

It's reading the text as not being changed while it actually has been changed via AutoIt. Any suggestions on circumventing this?

Link to comment
Share on other sites

azurekite,

Welcome to AutoIt and the forum!

Please make sure to read the forum rules.

Not allowed here is: "Bypassing of security measures - log-in and security dialogs"

So you won't get much help on this subject here.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

i was just about to post questi on did forum rules changed, hguess water is faster :P

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

bogQ,

Forum rules did change (on 2012-11-07) but automating logins is still not permitted.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • Moderators

Hi all,

Please read those Forum Rules carefully - I did mention when I posted them that there were some subtle changes. ;)

As quoted by water above, we do not permit discussion of "Bypassing of security measures - log-in and security dialogs". However, this is a simple web page and so automation in this case is permitted. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Yay, thank you Melba. I work for a company that uses this website and has certain levels of access to it including some backend systems and I'm trying to automate what we call the Scan Card Kiosk stations that way it'll automatically set itself up in the morning for the staff members who're coming in so they don't have to do it themselves. We rely on touchscreen systems for these kiosks and the touchscreen keyboard can get tiresome with this website. :P

Link to comment
Share on other sites

I always have read it as: A login is a login is a login.

I'm sure there is a reason for this subtle change - and I'm sure I missed it. Can anyone lend me a hand?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • Moderators

water,

I'm sure there is a reason for this subtle change - and I'm sure I missed it. Can anyone lend me a hand?

Just accept the fact that the rule was changed and we believed we had good reasons for doing so - trust me, you really do NOT want to know the details of how we got there. ;)

M23

Edited by Melba23
Typo

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Unfortunately not yet John. I'm attempting to go a different route on a second login page here: https://www.employflorida.com/loginintro.asp?logoff=true

It seems that this page uses iFrames though so I get to go play with the frame collection codes now. :D Even after changing oIE to oForm I still couldn't get the script to submit successfully. The javascript I posted earlier still seems to think something is equal to a default value and fails out.

(By the way it seems I can't make a post again until midnight, just an FYI. Don't want you thinking I'm not responding. I really appreciate all the input. :3)

Link to comment
Share on other sites

Just accept the fact that the rule was changed and we believed we had good reasons for doing so - trust me, you really do NOT want to know the details of how we got there. ;)

Accepting the wisdom of those who set up the rules is no problem ;) To remember the subtle differences when the next user asks the same question might be one - if it's still possible to post on Sunday ;)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Try this.

#include <IE.au3>
_IEErrorHandlerRegister()

$oIE = _IECreate("https://www.employflorida.com/vosnet/Default.aspx", 1, 1, 1, 1)
_IELoadWait($oIE)
$oForm = _IEFormGetObjByName($oIE, "aspnetForm")
$u_oObject = _IEFormElementGetObjByName($oForm, "ctl00$txtUsername")
_IEAction($u_oObject,"focus")
_IEFormElementSetValue($u_oObject, "blah")
$p_oObject = _IEFormElementGetObjByName($oForm, "ctl00$txtPassword2")
_IEAction($p_oObject,"focus")
_IEFormElementSetValue($p_oObject, "blah")
$go_submit = _IEGetObjByName($oForm, "ctl00$cmdLogin")
_IEAction($go_submit, "click")
;_IEFormSubmit($oForm)
Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

page that have some level of protection it self from inputting on password, even if it's dumb and small as its on that site,

and where autocomplete="off" is of for username, shud be considered as brakeing forum rules.

But it's stil dumb protection and i'll agree with Mod decision, and try to help ;)

so to JohnOne,

username you got correct

for password that will probably work but im not 100% shure, little trick goes like this ;)

$p_oObject = _IEFormElementGetObjByName($oForm, "ctl00$txtPassword")
$p_oObject2 = _IEFormElementGetObjByName($oForm, "ctl00$txtPassword2")
_IEAction($p_oObject2, "focus")
_IEFormElementSetValue($p_oObject, "password11")

(java focusing field on 1 of them in hope to protect one another...)

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

Hello again everyone,

I finally am able to post again (yay!) so I thought I'd post that my issue is now resolved. Thanks to everyone that posted here as it's thanks to you all that I was able to get this bad boy working.

#include 
_IEErrorHandlerRegister()

;EFM Username and Password
$efm_user = "username"
$efm_pass = "password"

;Kill all IE processes, if any
$exist_IE = ProcessExists ("iexplore.exe")
If $exist_IE Then
ProcessClose($exist_IE)
EndIf

;Open an new IE window leading to EFM and wait for it 500ms before checking if it is loaded
$oIE = _IECreate("https://www.employflorida.com/vosnet/Default.aspx", 1, 1, 1, 1)
_IELoadWait($oIE, 500)

;Load master form from main page
$oForm = _IEFormGetObjByName($oIE, "aspnetForm")

;Get username field and enter username
$u_oObject = _IEFormElementGetObjByName($oForm, "ctl00$txtUsername")
_IEAction($u_oObject,"focus")
_IEFormElementSetValue($u_oObject, $efm_user)

;Get password field and enter password
$p_oObject = _IEFormElementGetObjByName($oForm, "ctl00$txtPassword")
$p_oObject2 = _IEFormElementGetObjByName($oForm, "ctl00$txtPassword2")
_IEAction($p_oObject2,"focus")
_IEFormElementSetValue($p_oObject, $efm_pass)

;Get submit button, emulate a click, and wait for the page to load
$go_submit = _IEGetObjByName($oForm, "ctl00$cmdLogin")
_IEAction($go_submit, "click")
_IELoadWait($oIE, 500)

;Navigate to the scan card system and wait for the new page to load
_IENavigate($oIE, "https://www.employflorida.com/vosnet/staff/scankiosk.aspx")
_IELoadWait($oIE, 500)

;Put the window into fullscreen mode
_IEPropertySet($oIE, "theatermode", True)

This is now working wonderfully and I'm going to be continuing to use this and work on improving it. My next step is for the page that it navigates to. There are certain errors that occur when a user does something incorrectly. The interface is not very intuitive so these errors come up alot.

Once again, thanks everyone. :D

Link to comment
Share on other sites

page that have some level of protection it self from inputting on password, even if it's dumb and small as its on that site,

and where autocomplete="off" is of for username, shud be considered as brakeing forum rules.

But it's stil dumb protection and i'll agree with Mod decision, and try to help ;)

so to JohnOne,

username you got correct

for password that will probably work but im not 100% shure, little trick goes like this ;)

$p_oObject = _IEFormElementGetObjByName($oForm, "ctl00$txtPassword")
$p_oObject2 = _IEFormElementGetObjByName($oForm, "ctl00$txtPassword2")
_IEAction($p_oObject2, "focus")
_IEFormElementSetValue($p_oObject, "password11")

(java focusing field on 1 of them in hope to protect one another...)

Was just farting about with them, I believe the OP's problem was to get the form to submit

so was just really focusing on the endgame.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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...