SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 5 of 5
  1. #1
    Junior Member
    Join Date
    Apr 2004
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    TECHNICAL: httpunit form submission behavior with onsubmit attribute

    Hello,

    I have to submit this form :

    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">&lt;form method=&quot;post&quot; name=&quot;formulaireAuthentification&quot; onSubmit=&quot;valideFormulaire()&quot;&gt;
    ...
    &lt;input type=&quot;Image&quot; src=&quot;/graphismes/commandes/valider_horizon.gif&quot; width=&quot;60&quot; height=&quot;19&quot; border=&quot;0&quot; name=&quot;Image&quot;&gt;
    ...
    &lt;/form&gt;</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">In HttpUnit it gives me :

    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">WebForm form = resp.getFormWithName(&quot;formulaireAuthentificat ion&quot;
    ...
    resp = form.submit(form.getSubmitButton(&quot;Image&quot);</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">resp is my WebResponse instance.

    But resp is not update with the expected answer : I've got the same page and I can't go through my tests

    valideFormulaire() is a sequence of functions which update :

    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">document.formulaireAuthentification.ta rget=&quot;_top&quot; // indeed the form is in a frame that I selected previously
    document.formulaireAuthentification.action=&quot;h ttps://..../...&quot;</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">I verified that all the javascript code uses what Rhino library understands and it does.

    This is written in the javadoc of WebForm :

    public WebResponse submit(SubmitButton button)
    throws java.io.IOException,
    org.xml.sax.SAXException

    Submits this form using the web client from which it was originally obtained. Will usually return the result of that submission; however, if the submit button's 'onclick' or the form's 'onsubmit' event is triggered and inhibits the submission, will return the updated contents of the frame containing this form.

    I tried to find out if the content of the response has been changed but I didn't succeed. The request's parameters target and action still remain respectively wrong and empty [img]images/icons/confused.gif[/img]

    Have you got any idea to solve this problem ?
    --
    Laurent

  2. #2
    Member navskill's Avatar
    Join Date
    Dec 2003
    Location
    Denver Colorado
    Posts
    89
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: TECHNICAL: httpunit form submission behavior with onsubmit attribute

    Laurent,

    I am not having issues getting an HTTP response when using the submit method. I know my form under test is different from yours, but I am including pieces of the code I am using to test it.

    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">//Get Response 1 Main Search Page
    _response = _wc.getResponse(_request);
    _listOfForms = _response.getForms();
    _formCount = _listOfForms.length;
    ........
    //Build Request 2 (The Search you want to do)
    _request = _listOfForms[0].getRequest();
    _request.setParameter(...........
    ..........
    //Get Response 2 The First Page Of Results
    SubmitButton[] firstFormBtns;
    firstFormBtns =_listOfForms[0].getSubmitButtons();
    _response = _listOfForms[0].submit(firstFormBtns[0]);
    ..........</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">Here is my form that is under test:

    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">
    &lt;form name=nameSearch method=post action=search.jsp onSubmit=&quot;return validateAssetName(this)&quot;&gt;
    ....
    ....&lt;input type=submit value=Search&gt;
    &lt;/form&gt;</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">I know this didn't answer your question but I hope this helps a little.
    Derek

  3. #3
    Junior Member
    Join Date
    Apr 2004
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: TECHNICAL: httpunit form submission behavior with onsubmit attribute

    Thanks for the answer but it makes me a little more angry because my version should work [img]images/icons/smile.gif[/img]

    I need to solve the problem so I looked at the sources.

    I'm actually wondering about the behavior of this function :

    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;"> /**
    * Submits a request to the web client from which this request source was originally obtained.
    **/
    final
    protected WebResponse submitRequest( WebRequest request ) throws IOException, SAXException {
    // DEBUG TRACE
    System.err.println(&quot;WebForm.submitRequest(req uest) : [getDestination() = &quot; + getDestination() + &quot;];[getTarget() = &quot; + getTarget() + &quot;]&quot;
    System.err.println(&quot;WebForm.submitRequest(req uest) : [request = &quot; + request + &quot;];[request.getTarget() = &quot; + request.getTarget() + &quot;]&quot;

    return getDestination().equals( &quot;#&quot; )
    ? _baseResponse
    : _baseResponse.getWindow().sendRequest( request );
    }</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">This modified version gives me :

    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">WebForm.submitRequest(request) : [getDestination() = https://&lt;right address&gt;];[getTarget() = _top]
    WebForm.submitRequest(request) : [request = POST request for (&lt;right url which requests&gt; ) &lt;wrong query string&gt;];[request.getTarget() = &lt;wrong target&gt;]</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">Why the request is not accorded to the form destination and target attributes ?

    Is there anybody who noticed that and solved this mess ...
    --
    Laurent

  4. #4
    Member navskill's Avatar
    Join Date
    Dec 2003
    Location
    Denver Colorado
    Posts
    89
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: TECHNICAL: httpunit form submission behavior with onsubmit attribute

    Originally posted by Laurent:
    Why the request is not accorded to the form destination and target attributes ?
    <font size="2" face="Verdana, Arial, Helvetica">Laurent,

    I didn't see it in your original code snipet but did you call one of the getRequest methods for a Webform before you submitted the form?

    Navskill
    Derek

  5. #5
    Junior Member
    Join Date
    Apr 2004
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: TECHNICAL: httpunit form submission behavior with onsubmit attribute

    yes, I did

    Anyway I guess if you do it like this :
    form.setParameter("NumRef", ...);

    it's equivalent to :
    WebRequest req = form.getRequest();
    req.setParameter("NumRef", ...);

    The big problem is that the updating of the form attribute "action" and "target" are not used by the request of the form. In my case they are not present in the opening form tag.

    However, and it's good news, the interpretation of the javascript code is done right.
    --
    Laurent

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 11.11%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 02:04 PM.

Copyright BetaSoft Inc.