Question : Find button on form

Hi,
I'm trying to find a button on a webpage, so I can click it. First I find the form where it's contained.
I use this code:

final HtmlButton newDocButton = Form1.getButtonByName("cmdNewDoc");
assertNotNull("newDocButton doesn't return anything", newDocButton);
System.out.println("Found newDocButton.");
newDocButton.click();

But I get this error message:
Exception: com.gargoylesoftware.htmlunit.ElementNotFoundException: elementName=[button] attributeName=[name] attributeValue=[cmdNewDoc]

In what other way can I go looking for it?
Thank you,

Ana
Related Solutions: HtmlUnit to test webpages

Answer : Find button on form

try:

HtmlSubmitInput button = form.getInputByName("cmdNewDoc");
Random Solutions  
 
programming4us programming4us