WebAii 2.0 (Beta-v2.0.0.1) is ready for public consumption! Download it now from here.
Our 2.0 release is a big release. It contains tons of new features that we promised customers and have been working on for a while now. Our documentation for this release is being worked on as we speak.
Below is a break-down of all the main new features in 2.0!
1. Safari (Windows) Browser Support:
This is probably the feature that took the most effort to build but is the easiest to use. Simply set your “BrowserType” to Safari and your automation should execute against that browser. Make sure you have Safari installed though. That is Safari for Windows! You can also set that in your app.config file too.
You can easily test this feature out by taking one of your existing WebAii tests and simply switching the browser type to Safari. Who knows, you might find a new bug in your application ;)
Few things to keep in mind about our Safari support in this beta:
- We require Silverlight 2.0 to be installed on the machine. You will find out why as soon as you run your first test :)
- We currently do not support Html Pop-ups in Safari. That is something we are actively working on.
- Safari 4 Beta is currently NOT supported.
2. Silverlight Automation Support:
This version of WebAii contains all the functionality that we previewed in our Silverlight Extension CTPs here. If you are not familiar with our Silverlight support in WebAii, please take a look at our support overview discussed here.
In 2.0 we attempted to fix all reported bugs against the CTPs. We believe we have a solid platform for testing Silverlight applications and we will continue to invest in making it richer and simpler.
Here are some of the highlights of what we added/fixed since our last CTP:
- Performance Enhancements: Navigating the VisualTree is x100 faster now than the CTP.
- Expanded Control Support. All controls under System.Windows.Controls.Data & System.Windows.Controls are now available.
- Coordinates. There were minor bugs in how we calculate coordinates that we fixed.
- Highlight On/Off Support: You can turn highlighting on/off for a specific element.
- Support for Find.ByAutomationId: Although WebAii does not rely on UIAutomation, we know several customers have already invested in adding UIAutomation Ids to their UI components. It was easy for us to simply enable that as a mechanism for finding UI elements in the Visual Tree. So no effort wasted.
- ScrollToVisible: You now have the ability to scroll a specific visual element into visibility.
For example:
1: HyperlinkButton link = app.Find.ByName<HyperlinkButton>("link1"); 2: // Scroll the element to be visible within the browser
3: // area
4: link.ScrollToVisible();
5: // Or
6: link.ScrollToVisible(ScrollToVisibleType.ElementBottomAtWindowBottom);
7: // Or
8: link.ScrollToVisible(ScrollToVisibleType.ElementTopAtWindowTop);
3. Enhanced Debugging Support:
In previous WebAii versions, when you are broken in a debugger and you try to inspect an HtmlControl or a FrameworkElement object using the hover-over debugger tooltip, many times you ended up with timeouts in the debugger view. This issue should be fixed. You now can inspect all properties and even change them live in the debugger. It is actually pretty cool seeing the browser react to your debugger changes. Try it out with a TextBox!
4. Built-In HTTP Proxy:
In WebAii 2.0, you will notice a new Manager.Http namespace. Under that namespace, you will find the following methods:
You now have the ability to intercept raw http traffic under the cover. You can intercept an Http request before it is issued by the browser or intercept http responses before they are rendered by the browser.
This functionality will open up WebAii to be used in a wider range of automation scenarios like:
- Security Testing: In your listener you have access to all the basic Http Request/Response properties and you can inject, alter or do whatever you want with them.
- Performance Testing: You can use the http listeners to look at file sizes you are sending or receiving and even build regression unit tests that make sure your files don’t grow beyond a certain size!
- Page Synchronization: You can now sync your test to specific requests and have the ability to detect Ajax requests over the wire. We plan to add more easy OM for this similar to out Wait.Forxxx syntax.
Note: Make sure the Settings.UseHttpProxy is set to ‘true’ to allow this feature to function. This feature is off by default.
Here are some code samples that leverage the HttpProxy:
The following code shows how to inspect response types:
1: [TestMethod]
2: public void ImageDetection()
3: { 4: Manager.LaunchNewBrowser(BrowserType.InternetExplorer);
5: ResponseListenerInfo li = new ResponseListenerInfo(CheckTypeForImage);
6: Manager.Http.AddBeforeResponseListener(li);
7: ActiveBrowser.NavigateTo("http://news.google.com/"); 8: Manager.Http.RemoveBeforeResponseListener(li);
9: }
10:
11: private void CheckTypeForImage(object sender, HttpResponseEventArgs e)
12: { 13: Log.WriteLine(String.Format("Request for {0}", e.Response.Request.RequestUri)); 14: if (e.Response.IsImage)
15: { 16: Log.WriteLine(String.Format("Image detected; MIME type: {0}", 17: e.Response.Headers["Content-Type"]));
18: }
19: else
20: { 21: Log.WriteLine(String.Format("Not an image; MIME type: {0}", 22: e.Response.Headers["Content-Type"]));
23: }
24: }
You can also validate response sizes:
1: [TestMethod]
2: public void CheckImageSize()
3: { 4: ResponseListenerInfo li = new ResponseListenerInfo(Check);
5: Manager.Http.AddBeforeResponseListener(li);
6: Manager.LaunchNewBrowser();
7: ActiveBrowser.NavigateTo("http://my.homepage.com/"); 8: Assert.IsFalse(_imageTooLarge, "Some images in page >40k");
9: }
10:
11: private volatile bool _imageTooLarge = false;
12: private void Check(object sender, HttpResponseEventArgs e)
13: { 14: if (e.Response.IsImage && Int32.Parse(e.Response.Headers["Content-Length"]) > 40000)
15: { 16: _imageTooLarge = true;
17: }
18: }
5. Enhanced JavaScript Support:
There are some key scenarios here that we wanted to enable given the nature of today’s rich web applications that rely heavily on JavaScript. Below is a break-down of these features.
Make sure to include the ArtOfTest.WebAii.JavaScript namespace in your test first before trying these out.
1.Support for “eventArgs” for InvokeEvent: We had several customers request this. Now in addition to simply invoking an event with empty arguments, you can also include an event arg. We encapsulated all of that in one object called “ScriptEvent” and can be used with the InvokeEvent method. For example:
1: public void MouseEvents()
2: { 3: HtmlDiv target = Find.ById<HtmlDiv>("div1"); 4:
5: // middle-click on the div
6: MouseEvent arg1 = new MouseEvent("click"); 7: arg1.Button = MouseButton.Middle;
8: target.InvokeEvent(arg1);
9: }
2. Event Notification: You can now attach to javascript events on your page from your .NET code and have these events trigger an event handler in your test code. Here is an example:
1: private volatile bool _clickHandled;
2: private System.Threading.AutoResetEvent _clickARE;
3:
4: [TestMethod]
5: public void ClickHandler()
6: { 7: _clickARE = new System.Threading.AutoResetEvent(false);
8: _clickHandled = false;
9:
10: HtmlButton b = Find.ById<HtmlButton>("b"); 11:
12: // Attach a listener to the click event on the button.
13: b.AddEventListener("click", OnClick); 14:
15: // Invoke the event.
16: b.InvokeEvent(ScriptEventType.OnClick);
17:
18: // Wait until the event is fired.
19: _clickARE.WaitOne(500);
20:
21: Assert.IsTrue(_clickHandled);
22: }
23:
24:
25: private void OnClick(object sender, JavascriptEventArgs e)
26: { 27: _clickHandled = true;
28: _clickARE.Set();
29: }
3. Return JSON or Strongly-Typed objects from InvokeScript.Your tests can now understand JSON objects and can handle strongly typed objects returned from JavaScript. This might be a bit advanced for regular users but for customers building mini-frameworks on top of WebAii, it might be a great tool to get rid of having to parse back complex strings from InvokeScript. Here are a couple of samples on how to use this feature:
- Basic example using the built-in JsObject:
1: [TestMethod]
2: public void KeyValuePairs()
3: { 4: Manager.LaunchNewBrowser();
5:
6: // We are using a dummy call here. The call can be to any JS method on your page
7: JsonObject o = ActiveBrowser.Actions.InvokeScript<JsonObject>(
8: "({key1:'value1', key2:'value2'})"); 9:
10: Assert.AreEqual<string>("value1", o["root"]["key1"]); 11: Assert.AreEqual<string>("value2", o["root"]["key2"]); 12: }
- Or you can define your own object:
1: [DataContract]
2: public class MyObject
3: { 4: [DataMember(Name = "one")]
5: public int One { get; set; } 6: [DataMember(Name = "fifteen")]
7: public int Fifteen { get; set; } 8: }
9:
10: [TestMethod]
11: public void ReturnObject()
12: { 13: Manager.LaunchNewBrowser();
14: MyObject o = Actions.InvokeScript<MyObject>("({one:1, fifteen:15})"); 15: Assert.AreEqual<int>(1, o.One);
16: Assert.AreEqual<int>(15, o.Fifteen);
17: }
6. Firefox Execution Performance.
You will no longer see the weird mangled URL in the address bar and start-up time for firefox execution is faster than 1.1.
7. Firefox 3.1B/3.5 Support.
In case you plan to upgrade soon.
8. Extra HtmlControls like HtmlOrderedList & HtmlUnOrderedList.
9. Side By Side Support with WebAii 1.1 and Automation Design Canvas 1.1.
WebAii 2.0 Beta should run side by side with any previous WebAii installations on the machine.
DOWNLOAD 2.0 BETA NOW
We do hope you enjoy the new feature set and we look forward to your feedback!
The ArtOfTest Team.