I need to test a web application that uses buttons with JavaScript for navigation. I need to click these buttons. And I can't figure out, how to get to the buttons, since they are not a part of a form.
From reading the source it looks like HttpUnit 1.6's ParsedHTML class DOES handle your situation but not mine. It expects buttons outside forms to be one of these two styles:
<button type="button" ...>
<button ...> // ie. not type specified
Hi everybody!
I need to test a web application that uses buttons with JavaScript for navigation. I need to click these buttons. And I can't figure out, how to get to the buttons, since they are not a part of a form.
The code of the button is:
<BUTTON name="Continue" accesskey="C" class="formButton" onclick="window.open(...);"><U>C</U>ontinue</BUTTON>
and it may appear anywhere in the page.
Thanks for any ideas!
Hi,
I have the same problem - a button that is not part of a form - so it is not possible to use any of the WebForm.getButton... methods.
What about if we use
HTMLElement[] buttons = response.getElementsWithAttribute("type", "button");
is there a way to convert an HTMLElement to a Button?
Petr and Russell,
From reading the source it looks like HttpUnit 1.6's ParsedHTML class DOES handle your situation but not mine. It expects buttons outside forms to be one of these two styles:
<button type="button" ...>
<button ...> // ie. not type specified
To get, say, the first button try this:
HTMLElement[] buttons =
frame.getElementsWithAttribute("type", "button");
Button button = (Button) buttons[0];
My problem is caused by the web page using the input tag outside a form:
<input type="button" onclick="blahblah" value="OK">
Consequently, it can't be found by frame.getElementsWithAttribute("type", "button")
So, can someone help me?
Is it legitimate to modify ParsedHTML.newControlWithoutForm( ParsedHTML parsedHTML, Element element ) from doing this:
if (element.getNodeName().equalsIgnoreCase( "button" )
&& isValidNonFormButtonType( NodeUtils.getNodeAttribute( element, "type" ) ))
to doing this:
if ((element.getNodeName().equalsIgnoreCase( "button" )
|| element.getNodeName().equalsIgnoreCase( "input" ))
&& isValidNonFormButtonType( NodeUtils.getNodeAttribute( element, "type" ) ))
Mike