I've used the free edition of the WebAii test framework [the one released by Art Of Test before they were acquired by Telerik] quite a bit, so I know it basically works. So the problem I'm having now is completely baffling to me.
I'm trying to test navigation in an existing site, and going through a sequence of pages. I get to a page that has (among other things) two buttons. One is a "back" button that is an input element of type button with an onclick handler that calls a javascript function that just calls history.back(). The other is a submit button.
WebAii has no problem finding the submit button. But when I tell it to click it, it is, to all appearances, clicking the back button.
Here's the relevant HTML from the site:
<div align="right">
<table border="0" width="200" cellpadding="8" style="border-collapse: collapse" bordercolor="#E0DFE3">
<tr>
<td>
<input type="button" value="<- Back" name="B2" onclick="cancelChange()" >
</td>
<td>
<input type="submit" value="Maint Details ->" name="lnkSubmit">
</td>
</tr>
</table>
</div>
And here's the test code:
HtmlInputSubmit maintDetailsButton = Find.ByAttributes<HtmlInputSubmit>("value=Maint Details ->");
maintDetailsButton.Click();
Assert.IsTrue(ActiveBrowser.Url.Contains(expectedPage), "URL {0} does not contain expected page {1}", ActiveBrowser.Url, expectedPage);
The sequence of operations is working just fine when I click it manually, so I can see no evidence that it's the site's problem. I've seen abundant evidence that it is, in fact, clicking the "Back" button and not the "Maint Details" button. (Fiddler shows no request issued when the click request is sent - consistent with executing history.back(), since the browser simply redisplays from it's cache. When I click, it does, in fact, go to the previous page. And finally, if I remove the "onclick" attribute from the back button, so that clicking on the button does nothing, then when execute the test code, the site does nothing - simply stays on the current page.)
I am completely baffled. Can anyone give me a hint?