Sign in to follow this  
Followers 0
talkfoodtalk

Cannot Submit IE Form

8 posts in this topic

Hi I am trying to submit an IE Form:

<FORM encType=multipart/form-data method=post name=menuForm action=/nac-cp/default.html><TABLE>
<TBODY>
<TR>
<TD>Inspect:</TD>
<TD><INPUT onkeydown="if (event.keyCode == 13) {do_menu_form_submit('quickSearch_searchFieldId_');return false;};" title="<accessNode>:<rackId>-<shelfId>-<slotId>-[iMA#/BOND#]<portId> / <label> / <Id> / LABEL=<portlabel> / LBL=<portlabel> / CLABEL=<customerlabel> / CLBL=<customerlabel> / INSP=<Id> / INSPECTION=<Id>" value="BM0LCPLB:1-1-6-36  " type=text name=quickSearch_searchFieldId_> <INPUT type=hidden name=EventSource> <INPUT type=hidden name=stack> <INPUT type=hidden name=currentPosition> <INPUT value=81BF3F3055F23467DA83BE94A943C651.nwanalyser-nac-cp-jboss-slave-1 type=hidden name=JSESSIONID> </TD></TR></TBODY></TABLE></FORM>

The blow code does not work for me. There is no button for this form. From what I understand "onkeydown="if (event.keyCode == 13)" is the enter button. Does anyone know how I could gracefully send 'enter' to this without Winactivate or some such?

$na = _IEAttach("myurl.html", "url")
      Local $oForm = _IEFormGetObjByName($na, "menuForm")

      Local $oText = _IEFormElementGetObjByName($oForm, "quickSearch_searchFieldId_")
      _IEFormElementSetValue($oText, "Somedata")
    _IEAction($oForm, "$oForm")

Share this post


Link to post
Share on other sites



This line doesn't make any sense:

_IEAction($oForm, "$oForm")

Did you try:

_IEFormSubmit($oForm)

Share this post


Link to post
Share on other sites

You could also use ExecScript (search the forum for syntax / examples) if the standard _IEFormSubmit doesn't work.

Share this post


Link to post
Share on other sites

Hi Danp2

Sorry, I rushed that question.

Yes I did try   _IEFormSubmit($oForm) however that did not work. I'll do some research on ExecScript and let you know how it goes.

 

 

Cheers!

Share this post


Link to post
Share on other sites

I added below in

$na.Document.parentWindow.execScript("key = document.createEventObject(); key.keyCode = #{key}")
$na.Document.parentWindow.execScript("document.getElementById('#{element_id}').fireEvent('onkeydown', key)")

and

$oText.fire_keydown_on($oForm, 13)

But im still scratching my head.

Any suggestions how I can send 'enter' or a cariage return?

Share this post


Link to post
Share on other sites

Also _IEFormSubmit($oForm) does do somthing. It reloads the page that its on but it does not submit my input.......

Share this post


Link to post
Share on other sites

Just execute the code directly, as in:

$na.Document.parentWindow.execScript("do_menu_form_submit('quickSearch_searchFieldId_');")

Share this post


Link to post
Share on other sites

Ta daaa!! Excellent!!!

That works!

I was pulling my hair out with that one. I did try somthing similar to that earlier however I was puting my parentheses in the wrong place.

 

Thankyou soo much Danp2.

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
Sign in to follow this  
Followers 0

  • Similar Content

    • elbhiri
      By elbhiri
      i have two files a.au3 and b.au3 the both contains the same code which is :
      #include <IE.au3> #include <MsgBoxConstants.au3> Global $myUrl = "https://www.autoitscript.com" RegWrite('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main','SessionMerging','REG_DWORD','00000000') ShellExecute ("iexplore.exe", " -nosessionmerging about:blank") WinWait ("Blank Page") Global $oIE = _IEAttach ("about:blank", "url") _IELoadWait ($oIE) _IENavigate ($oIE, $myUrl) when i launch the both files in the same time two blank windows are opens.
      what im waiting for is that every window navigate to the link but what happen is the first and the second file navigate the url to the same window and the seconde window stay about:blank
      i think the problem happen because i try to open the same url in both windows
      so i need i way to navigate to the same url from two different windows
      Thanks in advance
    • HudsonKane
      By HudsonKane
      I have a page with several hundred <div>s, and each <div> has several hundred child <div>s, each with their own children
      when I use _IETagNameGetCollection($ie, "div", 0) I get them all, but I need to find a way to get say the 3rd child of the 5th child of the second top level <div>
      I have not yet been able to find anything along this line
      Is there any way to determine if an element is a child, parent, sibling?
      Thank you
    • kevin42036
      By kevin42036
      Hi All,

      I am very new to AutoIt and scripting in general and have a question about IEFormGetObjByName. The help function says:
      _IEFormGetObjByName ( ByRef $oObject, $sName [, $iIndex = 0] )
      But how do I find what to enter for $sName? In the example below, it says that it can be found by viewing the HTML source. So I went to the google home page, clicked Ctrl U to view the source, and cant figure out how they determined that the $sName is 'gbqf'. Can someone explain this process to me? Thanks in advance!
      ; Get a reference to a specific form by name.  In this case, submit a query
      ; to the Google search engine.  Note that the names of the form and form
      ; elements can be found by viewing the page HTML source
      #include <IE.au3>
      Local $oIE = _IECreate("http://www.google.com")
      Local $oForm = _IEFormGetObjByName($oIE, "gbqf")
      Local $oQuery = _IEFormElementGetObjByName($oForm, "q")
      _IEFormElementSetValue($oQuery, "AutoIt IE.au3")
      _IEFormSubmit($oForm)
       
    • mjolnirmarkiv
      By mjolnirmarkiv
      Hi!
      Does anyone have any idea why Test() returns 0, while Test2() returns 1?
      #include <IE.au3> MsgBox(0, "", Test() & " " & Test2()) Func Test() Local $oHTML = ObjCreate("HTMLFILE") $oHTML.body.innerHTML = FileRead("Test.html") Return IsObj($oHTML.getElementsByClassName("example")) EndFunc Func Test2() Local $oIE = _IEAttach("", "instance", 1) Return IsObj($oIE.document.getElementsByClassName("example")) EndFunc Sample Test.html I open in IE before testing:
      <!DOCTYPE html> <html> <body> <p class="example"></p> <div class="example"></div> </body> </html> I'm receiving html text in a response to http request, I need to parse it fast and easy, getElementsByClassName would have been ideal. I'm using 3.3.12.0 version.
    • ADIN
      By ADIN
      When at some page i access by  IE.au3 appears javascript alert all my code stops and i cant do nothing. Is there any way to stop executing javascript at this page or any way to force autoit to click "OK" when this alert appears?
       
      _IENavigate($oIE, "www.example.com") _IELoadWait($oIE) ; site is loaded and alert appears Send("{ENTER}") ;i want to close alert, this command is not executed, whole script is freeze ; cant do nothing more here....