You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by ZedroS Schwart <ze...@gmail.com> on 2006/03/20 23:27:47 UTC

[NewB] htmlUnit and submit button don't work...

Hi all

I'm trying to use htmlunit to test my Tapestry app.

Until a few time ago, it was going well : I could access the page, assert
some values and so on. Then I wanted to submit some values... I ge't the
error :
com.gargoylesoftware.htmlunit.ElementNotFoundException: elementName=[input]
attributeName=[name] attributeValue=[OK]

The interesting part of my Tests.java is, I think :
        URL url = new URL("Path");
        page = (HtmlPage) client.getPage(url);
        HtmlForm form = page.getFormByName("inscriptionForm");
        HtmlTextInput login = (HtmlTextInput) form.getInputByName("login");
        login.setValueAttribute("4car");
        HtmlSubmitInput ok = (HtmlSubmitInput) form.getInputByName("OK");

On the page file I have (extracts) :
    <property name="login"/>

    <component id="inscriptionForm" type="Form">
        <binding name="listener" value="listener:onOk"/>
        <binding name="delegate" value="beans.delegate"/>
    </component>

    <component id="login" type="TextField">
        <binding name="value" value="login"/>
        <binding name="validators" value="validators:required,minLength=6"/>

    </component>

On the html page I've (extracts):
      <form jwcid="inscriptionForm" >
            <tr>
              <td width="200"><label>Login (6 car min) :</label></td>
              <td><input jwcid="login" type="text" /></td>
            </tr>
            <tr>
              <td><input value="OK" type="submit" /></td>

Of course, my application works fine when manually testing it.

Could you please help me launch this "ok" button ?

Thanks in advance
ZedroS

Re: [NewB] htmlUnit and submit button don't work...

Posted by Mike Snare <mi...@gmail.com>.
You need to set the id attribute on the submit button.  You appear to
be searching for it by the name "OK", so use that.

-Mike

On 3/20/06, ZedroS Schwart <ze...@gmail.com> wrote:
> Hi all
>
> I'm trying to use htmlunit to test my Tapestry app.
>
> Until a few time ago, it was going well : I could access the page, assert
> some values and so on. Then I wanted to submit some values... I ge't the
> error :
> com.gargoylesoftware.htmlunit.ElementNotFoundException: elementName=[input]
> attributeName=[name] attributeValue=[OK]
>
> The interesting part of my Tests.java is, I think :
>        URL url = new URL("Path");
>        page = (HtmlPage) client.getPage(url);
>        HtmlForm form = page.getFormByName("inscriptionForm");
>        HtmlTextInput login = (HtmlTextInput) form.getInputByName("login");
>        login.setValueAttribute("4car");
>        HtmlSubmitInput ok = (HtmlSubmitInput) form.getInputByName("OK");
>
> On the page file I have (extracts) :
>    <property name="login"/>
>
>    <component id="inscriptionForm" type="Form">
>        <binding name="listener" value="listener:onOk"/>
>        <binding name="delegate" value="beans.delegate"/>
>    </component>
>
>    <component id="login" type="TextField">
>        <binding name="value" value="login"/>
>        <binding name="validators" value="validators:required,minLength=6"/>
>
>    </component>
>
> On the html page I've (extracts):
>      <form jwcid="inscriptionForm" >
>            <tr>
>              <td width="200"><label>Login (6 car min) :</label></td>
>              <td><input jwcid="login" type="text" /></td>
>            </tr>
>            <tr>
>              <td><input value="OK" type="submit" /></td>
>
> Of course, my application works fine when manually testing it.
>
> Could you please help me launch this "ok" button ?
>
> Thanks in advance
> ZedroS
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: [NewB] htmlUnit and submit button don't work...

Posted by ZedroS Schwart <ze...@gmail.com>.
Thanks a lot for your answers, you were right.

It was most helpful !

Re: [NewB] htmlUnit and submit button don't work...

Posted by Kent Tong <ke...@cpttm.org.mo>.
ZedroS Schwart <zedros.schwartz <at> gmail.com> writes:

> The interesting part of my Tests.java is, I think :
>         URL url = new URL("Path");
>         page = (HtmlPage) client.getPage(url);
>         HtmlForm form = page.getFormByName("inscriptionForm");
>         HtmlTextInput login = (HtmlTextInput) form.getInputByName("login");
>         login.setValueAttribute("4car");
>         HtmlSubmitInput ok = (HtmlSubmitInput) form.getInputByName("OK");

>             <td><input value="OK" type="submit" /></td>

Try:

              <td><input name="OK" value="OK" type="submit" /></td>

--
Author of a book for learning Tapestry (www.agileskills2.org/EWDT)


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org