QAInsight.net, QABlog.com, QABlog.net
Brent Strange's thoughts on Software Quality Assurance and technology

 
Monday, April 10, 2006
 
 

Forcing events to fire in SWEA

 
 

On our site we have validation controls (VAM) that we use with our forms to force valid data input. If the input is invalid then an error/label will appear. VAM will validate the form when events that are associated with the form elements are fired. In simple terms it looks like this:

  1. Enter invalid text into textbox
  2. Remove focus from textbox (click away)
  3. Error/label displays

Today in my automated test using SWEA, I couldn't get the error/label to display since IE doesn't fire the event when the value is changed programmatically. In order to get SWEA to display the error I needed to use SWEA's Invoke() method to invoke the OnChange event. This is what it looked like:

case TestGoal.ClientSideError1:
   //Enter a value into the textbox
   
((HtmlInputText)(IE.Scene["Zip"])).Value = zip;
   //Force the OnChange Event using Invoke()
   ((HtmlInputText)(IE.Scene["Zip"])).Invoke("Method_OnChange");
   myBrowser.Scene.WaitForActive(30000);
   //Validate the resulting error label
   Assert.AreEqual(message,
    ((HtmlContent)(IE.Scene["ClientMessage1"])).InnerHtml,
    "Incorrect message");
   break;


Alex helped me through this issue and told me that he would work on making SWEA cleverer by adding automatic event handling. Thanks for your help Alex!