Process a FORM with <input type="Image" ...>

View: New views
3 Messages — Rating Filter:   Alert me  

Process a FORM with <input type="Image" ...>

by Denis Molony :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have a form that I'm trying to use htmlunit to log-in somewhere, which looks like this:

<form name="CFForm_1" action="authenticate.cfm" method="POST" onsubmit="return _CF_checkCFForm_1(this)">

<tr>
  <td align=right><font class="Standard">Your Email</td>
  <td><input name="Emailaddress" id="Emailaddress" type="text" style="width:170px"  size="25"  class="Standard"  /></td>
</tr>

<tr>
  <td><font class="Standard">&nbsp;</td>
  <td><input type="Image" src="images/submit2.gif" width="108" height="20" border="0"></td>
</tr>

</form>

The problem is that the submit button is an image, and it has no name. On the example page, the button is obtained like this:
    final HtmlSubmitInput button = form.getInputByName("submitbutton");
My question is - how do I get the HtmlSubmitInput element in order to execute this line:

    final HtmlPage page2 = button.click();
I think what I need is form.getInputByType ("Image"), but that method doesn't seem to be exist. Is there another way do do this?





------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Htmlunit-user mailing list
Htmlunit-user@...
https://lists.sourceforge.net/lists/listinfo/htmlunit-user

Re: Process a FORM with <input type="Image" ...>

by Ahmed Ashour :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Dear Denis,
 
Try
 
HtmlImageInput input = page.getFirstByXPath("//image[@type='Image']");
input.click();
 
Yours,
Ahmed
----
Blog: http://asashour.blogspot.com

From: Denis Molony <dmolony@...>
To: htmlunit-user@...
Sent: Sat, November 7, 2009 1:56:02 PM
Subject: [Htmlunit-user] Process a FORM with <input type="Image" ...>

I have a form that I'm trying to use htmlunit to log-in somewhere, which looks like this:

<form name="CFForm_1" action="authenticate.cfm" method="POST" onsubmit="return _CF_checkCFForm_1(this)">

<tr>
  <td align=right><font class="Standard">Your Email</td>
  <td><input name="Emailaddress" id="Emailaddress" type="text" style="width:170px"  size="25"  class="Standard"  /></td>
</tr>

<tr>
  <td><font class="Standard">&nbsp;</td>
  <td><input type="Image" src="images/submit2.gif" width="108" height="20" border="0"></td>
</tr>

</form>

The problem is that the submit button is an image, and it has no name. On the example page, the button is obtained like this:
    final HtmlSubmitInput button = form.getInputByName("submitbutton");
My question is - how do I get the HtmlSubmitInput element in order to execute this line:

    final HtmlPage page2 = button.click();
I think what I need is form.getInputByType ("Image"), but that method doesn't seem to be exist. Is there another way do do this?






------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Htmlunit-user mailing list
Htmlunit-user@...
https://lists.sourceforge.net/lists/listinfo/htmlunit-user

Re: Process a FORM with <input type="Image" ...>

by Denis Molony :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Ahmed

Thanks for that. I got it to work with only minor modifications:

final HtmlImageInput input = page1.getFirstByXPath ("//input[@type='image']");

Interestingly, htmlunit converted the type attribute to lower case, so at first I couldn't find the tag.

Also, don't you think it would be better for the Form class to have a getInputByType() method? It already has other convenience methods for this sort of thing.

Thanks again.
  




On 07/11/2009, at 11:42 PM, Ahmed Ashour wrote:

Dear Denis,
 
Try
 
HtmlImageInput input = page.getFirstByXPath("//image[@type='Image']");
input.click();
 
Yours,
Ahmed
----
Blog: http://asashour.blogspot.com

From: Denis Molony <dmolony@...>
To: htmlunit-user@...
Sent: Sat, November 7, 2009 1:56:02 PM
Subject: [Htmlunit-user] Process a FORM with <input type="Image" ...>

I have a form that I'm trying to use htmlunit to log-in somewhere, which looks like this:

<form name="CFForm_1" action="authenticate.cfm" method="POST" onsubmit="return _CF_checkCFForm_1(this)">

<tr>
  <td align=right><font class="Standard">Your Email</td>
  <td><input name="Emailaddress" id="Emailaddress" type="text" style="width:170px"  size="25"  class="Standard"  /></td>
</tr>

<tr>
  <td><font class="Standard">&nbsp;</td>
  <td><input type="Image" src="images/submit2.gif" width="108" height="20" border="0"></td>
</tr>

</form>

The problem is that the submit button is an image, and it has no name. On the example page, the button is obtained like this:
    final HtmlSubmitInput button = form.getInputByName("submitbutton");
My question is - how do I get the HtmlSubmitInput element in order to execute this line:

    final HtmlPage page2 = button.click();
I think what I need is form.getInputByType ("Image"), but that method doesn't seem to be exist. Is there another way do do this?





------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july_______________________________________________
Htmlunit-user mailing list
Htmlunit-user@...
https://lists.sourceforge.net/lists/listinfo/htmlunit-user


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Htmlunit-user mailing list
Htmlunit-user@...
https://lists.sourceforge.net/lists/listinfo/htmlunit-user