Jump to content

Problem submitting javascript form/button in webpage


Recommended Posts

I am having a problem getting anything to click the "Continue" button on this form. It apears its a java script button/form. From reading in the help its best to use _IEAction("Click") but cant get that to work either. If I use _IEFormSubmit it will submit the form but the form gives an error as if it didnt get the data I plugged into it. but if I physically click the "Continue" button after my script types in the values it works fine. So I kinda think its a problem with the way the button it being pressed or the form is being submitted. 1082 is the index id that IEBuilder shows the button as having.

I am using IEBuilder to look under the hood of the webpage.

#include <IE.au3>
$oIE = _IECreate()
_IENavigate($oIE, "https://secure.logmeinrescue.com/US/HelpDesk/CreateTrial.aspx")

_IELinkClickByIndex ($oIE, 1082)
_IELinkClickByText ($oIE, "Continue")
$oSubmit = _IEGetObjByName ($oIE, "Button")
_IEAction ($oSubmit, "click")

Many thanks,

GD

Link to comment
Share on other sites

Hi GoogleDude !

#include <IE.au3>
$oIE = _IECreate ( )
_IENavigate ( $oIE, "https://secure.logmeinrescue.com/US/HelpDesk/CreateTrial.aspx" )
_IELoadWait ( $oIE )
$oSubmit = _IEGetObjByName ( $oIE, "Button1" )
$_innertext = _IEPropertyGet ( $oSubmit, "innertext" ) ; Complete Registration
ConsoleWrite ( '$_innertext : ' & $_innertext & @CRLF )
$_outerhtml = _IEPropertyGet ( $oSubmit, "outerhtml" ) ; <BUTTON id=Button1 onclick=validateTrial_Helpdesk_EN(); tabIndex=18 name=Button1>Complete Registration</BUTTON>
ConsoleWrite ( '$_outerhtml : ' & $_outerhtml & @CRLF )
_IEAction ( $oSubmit, "click" )

; another way
_IELoadWait ( $oIE )
$oForm = _IEFormGetObjByName ( $oIE, "createtrial" )
$oQuery = _IEFormElementGetObjByName ( $oForm, "Button1" )
$_innertext = _IEPropertyGet ( $oQuery, "innertext" ) 
ConsoleWrite ( '$_innertext : ' & $_innertext & @CRLF )
_IEAction ( $oQuery, "click" )

; another way
_IELoadWait ( $oIE )
$oDiv = _IEGetObjById ( $oIE, "Button1" )
_IEAction ( $oDiv, "click" )

; another way
_IELoadWait ( $oIE )
WinWait ( "LogMeIn - Register For Your Free Trial of LogMeIn Rescue - Windows Internet Explorer", '' )
WinActivate ( "LogMeIn - Register For Your Free Trial of LogMeIn Rescue - Windows Internet Explorer", '' )
WinWaitActive ( "LogMeIn - Register For Your Free Trial of LogMeIn Rescue - Windows Internet Explorer", '' )
ControlClick ( "LogMeIn - Register For Your Free Trial of LogMeIn Rescue - Windows Internet Explorer", '', "Button1", 'Left', 1 ) ; "[CLASS:Internet Explorer_Server; INSTANCE:1]" )
Exit

I use DebugBar v5.4.1, but nothing works...Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Hi GoogleDude !

#include <IE.au3>
$oIE = _IECreate ( )
_IENavigate ( $oIE, "https://secure.logmeinrescue.com/US/HelpDesk/CreateTrial.aspx" )
_IELoadWait ( $oIE )
$oSubmit = _IEGetObjByName ( $oIE, "Button1" )
$_innertext = _IEPropertyGet ( $oSubmit, "innertext" ) ; Complete Registration
ConsoleWrite ( '$_innertext : ' & $_innertext & @CRLF )
$_outerhtml = _IEPropertyGet ( $oSubmit, "outerhtml" ) ; <BUTTON id=Button1 onclick=validateTrial_Helpdesk_EN(); tabIndex=18 name=Button1>Complete Registration</BUTTON>
ConsoleWrite ( '$_outerhtml : ' & $_outerhtml & @CRLF )
_IEAction ( $oSubmit, "click" )

; another way
_IELoadWait ( $oIE )
$oForm = _IEFormGetObjByName ( $oIE, "createtrial" )
$oQuery = _IEFormElementGetObjByName ( $oForm, "Button1" )
$_innertext = _IEPropertyGet ( $oQuery, "innertext" ) 
ConsoleWrite ( '$_innertext : ' & $_innertext & @CRLF )
_IEAction ( $oQuery, "click" )

; another way
_IELoadWait ( $oIE )
$oDiv = _IEGetObjById ( $oIE, "Button1" )
_IEAction ( $oDiv, "click" )

; another way
_IELoadWait ( $oIE )
WinWait ( "LogMeIn - Register For Your Free Trial of LogMeIn Rescue - Windows Internet Explorer", '' )
WinActivate ( "LogMeIn - Register For Your Free Trial of LogMeIn Rescue - Windows Internet Explorer", '' )
WinWaitActive ( "LogMeIn - Register For Your Free Trial of LogMeIn Rescue - Windows Internet Explorer", '' )
ControlClick ( "LogMeIn - Register For Your Free Trial of LogMeIn Rescue - Windows Internet Explorer", '', "Button1", 'Left', 1 ) ; "[CLASS:Internet Explorer_Server; INSTANCE:1]" )
Exit

I use DebugBar v5.4.1, but nothing works...Posted Image

Hi thanks for tacking a stab at it. Im not sure how to get the button to click scriptomaticly. Anyone else have any ideas?

Thanks again for the help,

~GD

Link to comment
Share on other sites

No Image match to the button Posted Image

So _IEImgClick...

#include <IE.au3>
$oIE = _IECreate ( "https://secure.logmeinrescue.com/US/HelpDesk/CreateTrial.aspx" )
$oImgs = _IEImgGetCollection ( $oIE )
$iNumImg = @extended
ConsoleWrite ( "+>--- There are " & $iNumImg & " images on the page" & @Crlf )
Global $_I = 0, $_BGReturn=0, $_ImagesDirPath = @DesktopDir & '\Images on the page'
DirCreate ( $_ImagesDirPath )

For $oImg In $oImgs
    $_I = $_I +1
    $sInfo = " Src : " & $oImg.src & @CR
    $sInfo &= "->--- FileName: " & $oImg.nameProp & @CR
    $sInfo &= "->--- Height: " & $oImg.height & @CR
    $sInfo &= "->--- Width: " & $oImg.width & @CR
    $sInfo &= "->--- Border: " & $oImg.border
    ConsoleWrite ( @Crlf & "!>--- Image " & $_I & $sInfo & @Crlf )
    InetGet ( $oImg.src, $_ImagesDirPath & '\' & _GetFullNameByUrl ( $oImg.src ), $_BGReturn )
Next
_IEQuit ( $oIE )
ShellExecute ( $_ImagesDirPath )
Exit

Func _GetFullNameByUrl ( $_FileUrl )
    $_FileName = StringSplit ( $_FileUrl, '/' )
    If Not @error Then 
        Return $_FileName[$_FileName[0]]
    Else
        Return 0
    EndIf
EndFunc ;==> _GetFullNameByUrl ( )

Try to see if the function validateTrial_Helpdesk_EN() can help you...

Posted Image

I have tried this

#include <IE.au3>
$oIE = _IECreate ( )
_IENavigate ( $oIE, "https://secure.logmeinrescue.com/US/HelpDesk/CreateTrial.aspx" )
_IELoadWait ( $oIE )
Sleep ( 1000 )
_IELinkClickByIndex ( $oIE, 346 )

346 ==> View our privacy policy

347 ==> Log In to proceed. at bottom of the page.

So Continue Button is not a link...Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

There are more javascript functions you'd need to investigate that are called from that function, but furst I'd suggest trying the following sequence:

$oSubmit.fireEvent("onmousedown")

$oSubmit.fireEvent("onmouseup")

_IEAction ($oSubmit, "click")

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

There are more javascript functions you'd need to investigate that are called from that function, but furst I'd suggest trying the following sequence:

$oSubmit.fireEvent("onmousedown")

$oSubmit.fireEvent("onmouseup")

_IEAction ($oSubmit, "click")

Dale

Thanks Dale ! Posted Image

#include <IE.au3>
$oIE = _IECreate ( )
_IENavigate ( $oIE, "https://secure.logmeinrescue.com/US/HelpDesk/CreateTrial.aspx" )
_IELoadWait ( $oIE )
$oSubmit = _IEGetObjByName ( $oIE, "Button1" )
$oSubmit.fireEvent ( "onmousedown" ) ; True
_IEAction ( $oSubmit, "click" )

No errors, but nothing happens ! this button is strange ! Posted Image

I try to see if with _IEPropertyGet function it can be possible to get coordinates of button and use mouseclick on...

but i get number bigger than my screen size, so...

Or another idea ?

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Well I was kinda able to get it to work sonsistantly by using SEND() with a bunch of TABBing to to jump to each object. Its not Ideal but working I guess. The strange thing is on the second page of that same form the _IEFormSubmit() is working but not on the First Page. On the first page of the form when it submits the form it does not pass the data along with it unless the Continue button it physically pressed.

Thanks,

~GD

Link to comment
Share on other sites

See the "Automate input type=file" link in my sig for a code sample.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

You want to click the Continue button? it does not have an id of Button1... you'll need to find another way to select it. Perhaps:

$oButton = _IETagnameGetCollection($oIE, "button", 1) ; it is the second button tag on the page.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

See the "Automate input type=file" link in my sig for a code sample.

Dale

Thanks Dale !

And sorry for the post on the wrong thread Posted Image

I'm lost with all this reseach , all this tests inconclusive and I don't know what to do to with this damned button !

#include <IE.au3>

$oIE = _IECreate ( )
_IENavigate ( $oIE, "https://secure.logmeinrescue.com/US/HelpDesk/CreateTrial.aspx" )
_IELoadWait ( $oIE )
$oT = _IEGetObjById ( $oIE, 'Button1' )
$oscreenx = _IEPropertyGet ( $oT, "screenx" )
$owidth = _IEPropertyGet ( $oT, "width")
$oscreeny = _IEPropertyGet ( $oT, "screeny" )
$oheight = _IEPropertyGet ( $oT, "height" )/2
ConsoleWrite ( $oscreenx & " + " & $owidth & ' -10, ' & $oscreeny & " + " & $oheight & @Crlf )
MouseClick ( "left", $oscreenx + $owidth - 10, $oscreeny + $oheight, 1 )

I already try like this and each time width and height return zero

and the y Coordinates is bigger than my screen size ! Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

You want to click the Continue button? it does not have an id of Button1... you'll need to find another way to select it. Perhaps:

$oButton = _IETagnameGetCollection($oIE, "button", 1) ; it is the second button tag on the page.

Dale

I thinked this was Button1 because i have found :

; <TD class="gray full" style="TEXT-ALIGN: center" colSpan=2><SPAN class="button blue"><SPAN class=left></SPAN><SPAN class=middle><BUTTON onclick="if(validateTrial_Helpdesk_Page1_EN()) switch_pages(document.getElementById('firstpage'), document.getElementById('secondpage'))" tabIndex=8>&nbsp;Continue&nbsp;</BUTTON></SPAN><SPAN class=right> </SPAN></SPAN></TD>

; <TD class="gray fields"><SPAN class="button blue"><SPAN class=left></SPAN><SPAN class=middle><BUTTON id=Button1 onclick=validateTrial_Helpdesk_EN(); tabIndex=18 name=Button1>Complete Registration</BUTTON></SPAN><SPAN class=right> </SPAN>

And Debugbar does'nt show another button's name...

Usually i get there but this one is hard !

So I'll try _IETagnameGetCollection

Thanks again !

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Hey ! GoogleDude, It works !

Thanks Dale ! You're the best ! Posted Image

$oIE = _IECreate ( )
_IENavigate ( $oIE, "https://secure.logmeinrescue.com/US/HelpDesk/CreateTrial.aspx" )
;_IELoadWait ( $oIE )
$oButton = _IETagnameGetCollection ( $oIE, "button", 1 ) ; it is the second button tag on the page.
_IEAction ( $oButton, "click" )

And one tablet of aspirin for my head...

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Just a note... _IENavigate calls _IELoadWait automatically unless you disable it, so no need for the extra call

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

  • 8 months later...

OK I finally made it back to the hotel. :huh2:

I know its been a while but im back @ this script again and still am unable to get the form to submit on page 2. The only way I was able to get the form to submit on page 1 was to TAB all the way to it. which is kinda a messy way of doing it. But the TABing on page 2 seams to be dynamic or something. below is a mock up of what im using. I have tried several diff. things so there are a few things commented out but the below sample should get to to page 2 of the form and not actualy submit it.

Can anyone get it to submit?

#include 
#include <IE.au3>

$randomemail = "myemail@gmail.com"
$PhoneNumber = "123-456-7890"
$CompanyName = "My Company"
$Country = "us"
$FirstName = "My Name"
$LastName = "Last Name"
$State = "ok"
$LMIPassword = "Password001"

Call("MyFunc")

Func MyFunc()
    $oIE = _IECreate("https://secure.logmeinrescue.com/US/HelpDesk/CreateTrial.aspx",0,1,1,1)
    ; get pointers to the registration form on page 1
    $o_form = _IEFormGetObjByName($oIE, "createtrial")
    $o_email = _IEFormElementGetObjByName($o_form, "email1")
    _IEFormElementSetValue($o_email, $randomemail )
    $o_reemail = _IEFormElementGetObjByName($o_form, "reemail")
    _IEFormElementSetValue($o_reemail, $randomemail )
    $o_password = _IEFormElementGetObjByName($o_form, "password")
    _IEFormElementSetValue($o_password, $LMIPassword)
    $o_repassword = _IEFormElementGetObjByName($o_form, "repassword")
    _IEFormElementSetValue($o_repassword, $LMIPassword)
    $o_country_only = _IEFormElementGetObjByName($o_form, "country_only")
    _IEFormElementSetValue($o_country_only, "US")
    $o_supporting = _IEFormElementGetObjByName($o_form, "supporting")
    _IEFormElementSetValue($o_supporting, "3")
    TrayTip("Please wait.....", "Proceeding to step 2.", 30)
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{SPACE}")
    $o_form = _IEFormGetObjByName($oIE, "createtrial")
    $o_fname = _IEFormElementGetObjByName($o_form, "fname")
    _IEFormElementSetValue($o_fname, $FirstName)
    $o_lname = _IEFormElementGetObjByName($o_form, "lname")
    _IEFormElementSetValue($o_lname, $LastName)
    $o_org = _IEFormElementGetObjByName($o_form, "org")
    _IEFormElementSetValue($o_org, $CompanyName)
    $o_country = _IEFormElementGetObjByName($o_form, "country")
    _IEFormElementSetValue($o_country, $Country)
    $o_state = _IEFormElementGetObjByName($o_form, "state")
    _IEFormElementSetValue($o_state, $State)
    $o_phone = _IEFormElementGetObjByName($o_form, "phone")
    _IEFormElementSetValue($o_phone, $PhoneNumber)
    $o_problems = _IEFormElementGetObjByName($o_form, "problems")
    _IEFormElementSetValue($o_problems, "Fix problems on computers")
    $o_terms = _IEFormElementGetObjByName($o_form, "readTermsConditions")
    _IEFormElementSetValue($o_terms, "1")
    _IEFormSubmit($o_form)
EndFunc
Edited by GoogleDude
Link to comment
Share on other sites

As you note, there is a lot of Javascript behind that form, including a large field validation routine. Something in it is preventing the form submission (some condition not being met.

Another thing you can try is simply to override the validation script or replace it with your own.

For example:

IEHeadInsertScript($oIE, "function validateTrial_Helpdesk_EN() { return true; }")

Func IEHeadInsertScript($o_object, $s_script)
    Local $o_head, $o_element
    $o_head = _IETagNameGetCollection($o_object, "head", 0)
    $o_element = $o_object.document.createElement('script')
    $o_element.type = 'text/javascript'
    $o_element.text = $s_script
    $o_head.appendChild($o_element)
    Return 1
EndFunc   ;==>IEHeadInsertScript

Dale

Edited by DaleHohm

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Tested with your form and it still isn't the answer, but it gives you another tool to try.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

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