|
From: <Mik...@su...> - 2002-11-15 18:45:36
|
What you're doing looks correct. You might try a few things:
1) Play around with the case of your names, e.g. try "input" instead of "INPUT".
2) Put quotes around all your attributes, e.g. name="btnSignin".
Here's a few examples I have on hand.
protected HtmlPage clickOnAnchor( HtmlPage page, String id) throws Exception
{
HtmlAnchor anchorElement = (HtmlAnchor)page.getHtmlElementById( id);
return (HtmlPage)anchorElement.click();
}
protected HtmlPage clickOnRadioButton( HtmlPage page, String id) throws
Exception {
HtmlRadioButtonInput inputElement
= (HtmlRadioButtonInput)page.getHtmlElementById( id);
return (HtmlPage)inputElement.click();
}
protected HtmlPage setSelectedAttribute( HtmlPage page, String
selectElementId, String attribute, boolean isSelected) {
HtmlSelect selectElement = (HtmlSelect)page.getHtmlElementById(
selectElementId);
return (HtmlPage)selectElement.setSelectedAttribute( attribute,
isSelected);
}
protected HtmlPage setInputValue( HtmlPage page, String inputElementName,
String value) {
HtmlInput inputElement = (HtmlInput) page.getOneHtmlElementByAttribute
("input", "name", inputElementName);
inputElement.setValueAttribute( value);
return page;
}
Mike
|---------+-------------------------------------------->
| | "Goudreau, David" |
| | <DGo...@qr...> |
| | Sent by: |
| | htm...@li...|
| | ceforge.net |
| | |
| | |
| | 11/15/2002 12:35 PM |
| | |
|---------+-------------------------------------------->
>--------------------------------------------------------------------------------------------------------------|
| |
| To: "'htm...@li...'" <htm...@li...> |
| cc: |
| Subject: [HtmlUnit] Sample code using HtmlUnit? |
>--------------------------------------------------------------------------------------------------------------|
I saw the tables code sample, but I'm wondering if someone could post some
other basic code snippits, like getting a page, filling in text boxes, then
submitting the form. Specifically, I'm having difficulty getting an
HtmImageInput object from my page so that I can call click() on it and
submit the form. At the moment I have
HtmlImageInput submitFormButton = (HtmlImageInput)
loginPage.getOneHtmlElementByAttribute("INPUT", "name", "btnSignin");
but I get an ElementNotFound exception. My HTML looks like
<INPUT type=image height=27 alt="Log in" width=31 src="login.gif" border=0
name=btnSignin>
Any help is greatly appreciated.
-David
-------------------------------------------------------
This sf.net email is sponsored by: To learn the basics of securing
your web site with SSL, click here to get a FREE TRIAL of a Thawte
Server Certificate: http://www.gothawte.com/rd524.html
_______________________________________________
HtmlUnit-develop mailing list
Htm...@li...
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop
|