Jump to content

_IEFormSubmit with a Post -method


 Share

Recommended Posts

Hello All

I was trying to automate the submitting of a Form. The form itself has got the "post" method defined (instead of the more common "get").

Two questions :

1) For some reason the "_IEFormSubmit" does not seem to include the the "value" of the submit-button in the post-data. Is something wrong with the command, or am I missing something here ?

2) How can I select, when there are more than one submit-buttons in a form, which one to send when using the "_IEFormSubmit" command ?

P.s.

I did just look at "_IEFormSubmit"-s code (located in the "ie.au3" file), but have to little experience with COM-objects to see what could/has to be changed. But I could do with a hint or two :lmao:

Link to comment
Share on other sites

Please read the helpfile for _IESubmit():

Remarks

For many HTML forms it is not sufficient to use _IEFormSubmit() because there is often custom Javascript tied to an onclick event for its Submit button. In these cases you'll need to simulate a click of the submit button instead of using _IEFormSubmit(). See the example for the "click" action of _IEAction().

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

  • Moderators

I was trying to automate the submitting of a Form. The form itself has got the "post" method defined (instead of the more common "get").

They are both very common, "post" sends data and "get" retrieves data.

1) For some reason the "_IEFormSubmit" does not seem to include the the "value" of the submit-button in the post-data. Is something wrong with the command, or am I missing something here ?

The "value" of the submit button just defines what text is displayed.

2) How can I select, when there are more than one submit-buttons in a form, which one to send when using the "_IEFormSubmit" command ?

The best solution currently is to get a reference to the button and use _IEAction($oButton, "click").
Link to comment
Share on other sites

Please read the helpfile for _IESubmit():

Dale

Yes, I did read that. Could you explain to me how you think that that information is linked to my problem ?

Could it be that you are assuming (why or how I don't know) that that submit-button has got javascript linked to it ? FYI : it does not :lmao:

Link to comment
Share on other sites

They are both very common, "post" sends data and "get" retrieves data.

Both methods both send, and retrieve data. The only difference is in how the data is transmitted (as part of the URL, or as seperate data following the header).

The "post" method is not often needed, as most user-provided information is small enough to be appended to the URL.

The "value" of the submit button just defines what text is displayed.

and what gets send (or should be send) as the value to the key that is taken from the "name" property of the input-element with the "submit" -style.

FYI : I intercepted and looked at what got send when using the "_IEFormSubmit()" command, or while clicking the mouse on the submit-button (not using AI at all). As you can see I've done my homework. :lmao:

The best solution currently is to get a reference to the button and use _IEAction($oButton, "click").

Yes, I know. That command was mentioned in the "remarks" section in AI's Help to the _IEFormSubmit() command, and I used it to work around the problem.

Lets put it simpler : what is the "_IEFormSubmit()" command good for when trying to "post" some data, when it "forgets" to add the submit-button name-contents to the send data (making the server ignore/refuse the data) ?

Link to comment
Share on other sites

  • Moderators

Both methods both send, and retrieve data. The only difference is in how the data is transmitted (as part of the URL, or as seperate data following the header).

I stand corrected. The server side of things is not my strong point.

get: Append the arguments to the action URL and open it as if it were an anchor.

post: Send the data through an HTTP post transaction.

When using the post method, there is no theoretical limit to the amount of data that can be sent to the HTTP server. The amount of data may be constrained by the physical limits of the client computer.

When using the get method to send data to an HTTP server, the amount of data that can be sent is limited by the maximum length of a URL. In this case the URL cannot be longer than 2048 bytes.

The "post" method is not often needed, as most user-provided information is small enough to be appended to the URL.and what gets send (or should be send) as the value to the key that is taken from the "name" property of the input-element with the "submit" -style.

I was unaware of this, but after some searching I finally found this.

If the user clicks the Submit button to submit the form, and that button has a name attribute specified, that button contributes a name/value pair to the submitted data.

Lets put it simpler : what is the "_IEFormSubmit()" command good for when trying to "post" some data, when it "forgets" to add the submit-button name-contents to the send data (making the server ignore/refuse the data) ?

It is good for submitting most forms. However the .Submit method does not provide the ability to include the name/value with the sumbitted data. I've searched for a workaround, but all I've been able to come up with so far is using the .Click method.
Link to comment
Share on other sites

<snip>

I stand corrected. The server side of things is not my strong point.

<snip differences between "get" and "post">

Yep, that's the difference.

<snip>

I was unaware of this, but after some searching I finally found this.

<snip question about the usage of "_IEFormSubmit()">

It is good for submitting most forms. However the .Submit method does not provide the ability to include the name/value with the sumbitted data.

To me that (not including the submit-buttons name/value pair) sounds a bit strange, as most all forms submit their data by pressing such a button (even this very forum, at the bottom of its topics-listing pages).

But thanks for confirming that behaviour, I was afraid that I missed something somewhere :lmao::ph34r:

I've searched for a workaround, but all I've been able to come up with so far is using the .Click method.

Again, thanks.
Link to comment
Share on other sites

Sorry you didn't find my responsemore helpful. It did point you to the answer but I didn't have time at that moment to explain.

Lets put it simpler : what is the "_IEFormSubmit()" command good for when trying to "post" some data, when it "forgets" to add the submit-button name-contents to the send data (making the server ignore/refuse the data) ?

Exactly. _IEFormSubmit() simply executes the DOM form method .Submit With a very large percentage of the forms developed on the web today this is insufficient. The most common issue is the javascript event issue that I documented in the helpfile. As you point out, this is another. I had assumed that the default submit button name/value pair was transmitted, but a quick test in Fiddler shows that no submit button name/value pair is passed when the Submit method is used. This will be worth documenting for _IEFormSubmit().

Fortunately, there is a simple workaround by using _IEAction click on the desired button.

The default action for .Submit works for a significant percentage of forms today, but the exceptions are becomming more and more common.

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

Sorry you didn't find my responsemore helpful. It did point you to the answer but I didn't have time at that moment to explain.

You've made up for that with your current explanation. :lmao:

<snip>

Exactly. _IEFormSubmit() simply executes the DOM form method .Submit

I allready thought I recognized that when looking into the funcion in the IE.au3 -file, but was not sure about it.

With a very large percentage of the forms developed on the web today this is insufficient. ... This will be worth documenting for _IEFormSubmit().

Thanks. As I mentioned to big_daddy I was afraid I missed something obvious here, and am glad to hear I didn't.

And yes, although this is not exactly an AI problem, I think its worth mentioning.

The default action for .Submit works for a significant percentage of forms today, but the exceptions are becomming more and more common.

I will certainly take more notice of Forms in the future, just to see if I can find any that do not use submit-buttons (and how they than do submit their data). :ph34r:

Thanks for your reply,

BitRot

Link to comment
Share on other sites

  • Moderators

I will certainly take more notice of Forms in the future, just to see if I can find any that do not use submit-buttons (and how they than do submit their data). :lmao:

I think you are misunderstanding the problem. It is not that they don't use a submit button, its that they don't require a name/value pair from the submit button. When in doubt you can use something like this.

$oElements = _IEFormElementGetCollection($oForm)
For $oElement In $oElements
    If $oElement.type = "submit" Then
        If String($oElement.name) = "" Then
            _IEFormSubmit($oForm)
            ExitLoop
        Else
            _IEAction($oElement, "click")
            _IELoadWait($oIE)
            ExitLoop
        EndIf
    EndIf
Next
Link to comment
Share on other sites

I think you are misunderstanding the problem. It is not that they don't use a submit button, its that they don't require a name/value pair from the submit button.

Hmm. Not having a name/value pair in the submit-button is not a problem to me. Having that data, but not using it is. :lmao:

In other words : I'm a bit confused to what the developers of IE might have been thinking at the time they implemented the .Submit method :

In most (if not all) cases a button needs to be clicked to submit the form-data, which than adds, when present, its name and value to the submitted data.

But when the .Submit method is used the (mostly single) input-element with the "submit"-style is fully ignored. :ph34r:

Somehow I fail to see the logic in this. :ph34r:

When in doubt you can use something like this.

<snip>

Good call. I'm tempted to re-write the "_IEFormSubmit()" function so that it does that automatically. :)

I can than allso include the possibility to press another "submit"-button than the first one. :geek:

Link to comment
Share on other sites

  • Moderators

In other words : I'm a bit confused to what the developers of IE might have been thinking at the time they implemented the .Submit method :

I had the same thought when I read the description for the .Submit method.

Good call. I'm tempted to re-write the "_IEFormSubmit()" function so that it does that automatically. :ph34r:

I can than allso include the possibility to press another "submit"-button than the first one. :lmao:

Thanks.

Yes it would be nice to be able to specify which submit button by name or index.

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