Does this work with asp.net mvc on IE7 and 8? Its not working for me. It doesn't work on Chrome either but it works fine on Firefox. Right now the control just runs through but nothing really happens. The code we have is under:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<div id="SeachBar">
<form id="search" action="<%= Url.Action("Search", "Songs") %>">
<fieldset>
<input id="query" type="text" name="query" />
<input id="Search" type="submit" value="Search" />
</fieldset>
</form>
</div>
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<div id="SearchBar"> <form id="search" action="<%= Url.Action("Search", "Songs") %>" class="ajax">
<fieldset> <input id="query" type="text" name="query" />
<input id="Search" type="submit" value="Search" /> </fieldset>
</form></div>
The test case:
HtmlElement searchBar = page.Elements.Find("SeachBar");
HtmlInputElement txtBox = (HtmlInputElement)searchBar.ChildElements.Find(SearchTextBox);
txtBox.SetText("a"); // Search with a text "a"
txtBox.DispatchEvent(new HtmlKeyEvent("KeyPress") { KeyCode = 13 });
System.Threading.Thread.Sleep(2000);
page.Elements.Refresh();
Assert.IsTrue(page.Elements.Exists(SearchResults)); // If the results table comes up then the test is pass.
Need help on this.
IE just just runs thru the dispatch element but the enter click does not happen.
Chrome throws an exception :
Exception was thrown by the client engine: "[TestExecutorException]: Unhandled JS exception while executing command handler function DispatchKeyEvent. (Details: {\"message\":\"Object #<a KeyboardEvent> has no method 'initKeyEvent'\",\"stack\":\"TypeError: Object #<a KeyboardEvent> has no method 'initKeyEvent'\\n at [object Object].invokeKeyEventInternalWithArgs