Hi,
First off im new here and fairly new to java scripting. So try and take it easy. :o
The issue im having is i keep getting a cast error when running the code below. i am using HtmlUnit to try and submit a form online for me. here is the error:
and here is my code:Quote:
Exception in thread "main" java.lang.ClassCastException: com.gargoylesoftware.htmlunit.html.HtmlButtonInput cannot be cast to com.gargoylesoftware.htmlunit.html.HtmlSubmitInput
at formfillerbot.fill(formfillerbot.java:24)
at formfillerbot.main(formfillerbot.java:30)
The xxxxxx are taking up name slots and other items which i know are valid. Any help you could give would be great!Code:import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
import com.gargoylesoftware.htmlunit.html.HtmlRadioButtonInput;;
public class formfillerbot {
private String bUrl;
public formfillerbot (String url) throws Exception {
bUrl = url;
}
public void fill () throws Exception{
WebClient wb = new WebClient ();
Page p = (HtmlPage) wb.getPage(bUrl);
HtmlForm f = ((HtmlPage) p).getFormByName("xxxxxxxx");
HtmlRadioButtonInput r = f.getElementById("xxxxxxxxxx");
r.click();
HtmlSubmitInput s = (HtmlSubmitInput) f.getInputByName("xxxxxxxxx");
System.out.println(s.asText());
}
public static void main (String args[]) throws Exception {
formfillerbot xyro = new formfillerbot ("http://xxxxxxxx.xxxxxx");
xyro.fill ();
}
}
Nat
