May 11, 2006

Ajax Support is Coming!

ABCWebTest will soon support automated testing of Ajax applications!

With the next release of ABCWebTest it will be possible to automate the testing of Ajax applications such as Google Maps. You'll be able to move the mouse over any element on a web page (e.g. a zoom slider image) drag the mouse in either a vertical or horizontal direction (e.g. dragging a map or dragging a zoom slider up or down to zoom in on the map). ABCWebTest will automatically wait until the Ajax application has updated all the data before returning from a method call.

This means you, as the test writer, don't have to worry about putting in timers/waits/sleeps until the Ajax operation is finished. You'll just use this simple API (example code is testing the Google Maps site):

C#

Image sliderImage = browser.Document.GetImageBySrc("slider.png");
browser.Mouse.MoveOverElement(sliderImage);
browser.Mouse.DragVertically(20); //zoom in on map - move slider up by 20 pixels


Java

Image sliderImage = browser.getDocument().getImageBySrc("slider.png");
browser.getMouse().moveOverElement(sliderImage);
browser.getMouse().dragVertically(20); //zoom in on map - move slider up by 20 pixels


Stay tuned for more details...

Posted by Misha Rybalov at 07:01 AM | Comments (0)

May 09, 2006

The Need for Speed - ABCWebTest is now FAST!

One of the most frequent feedback comments we've received about ABCWebTest is the request to speed up it's execution. We've listened and it's now super-fast!

The main issue before was that in order to ensure that the web page was loaded properly, we had to put in many checks. What we've done since version 0.5 is created a Speed class that allows you to control the speed at which your tests are executing. Think of it like a manual transmission car, except here we only have 2 speeds: low and high. By default, the speed of ABCWebTest is as fast as possible, which should suffice for most situations. However, there will be times when you'll need to slow it down. This is usually the case right before an action opens a popup. In that case, you'd simply slow down ABCWebTest before the action that causes the popup to occur and then speed it back up right after. Here's some sample code in C#:


browser.Speed.SlowDown();
browser.Document.GetAnyButtonByName("click_me_to_open_popup").Click();
browser.Speed.SpeedUp();

Here's the same code in Java:


browser.getSpeed().slowDown();
browser.getDocument().getAnyButtonByName("click_me_to_open_popup").click();
browser.getSpeed().speedUp();


You can change the low and high speed values as you require, but by default the high speed is "0" and the low speed is "1000". This is the approximate number of milliseconds of delay. The higher the value, the larger the delay and the slower your web tests will take to run. Here's how you would change the default speed values:

C#:


browser.Speed.High = 100; //slow down high speed to 100ms instead of the default 0ms
browser.Speed.Low = 800; //speed up low speed to 800ms instead of the default 1000ms

Java:


browser.getSpeed().setHigh(100); //slow down high speed to 100ms instead of the default 0ms
browser.getSpeed().setLow(800); //speed up low speed to 800ms instead of the default 1000ms

The speed increase is available in ABCWebTest as of version 0.5.

Posted by Misha Rybalov at 03:03 PM | Comments (0)

May 03, 2006

Dealing with Frustrating Development Issues - Part 2 (The End)

As I previously wrote I was having some issues with trying to get a parent window from MSHTML.IHTMLDocument2. Turns out that the issue is the NUnit GUI!

Who would have thought that a unit testing tool affects how you have to write your core application code, but that seems to be the case. No wonder running these tests worked previously - I was using the NUnit console application. When you use the NUnit GUI, you have to take into account that it uses MTA (multi-threaded apartment threading model) by default. The way I got my code to work was to set the default threading model to STA (single-threaded apartment) like so:

System.Threading.Thread.CurrentThread.ApartmentState = System.Threading.ApartmentState.STA;

The reason this is necessary is because the call to IHTMLDocument2.parentElement has to be done from the main thread. Otherwise you get a nasty System.InvalidCastException. If you're running the NUnit console, it's not a problem because the main thread is the test thread. But if you're running the NUnit GUI, the main thread is the GUI thread so I kept running up against that nasty exception. Setting your code to run in STA mode fixes this problem.

After hours of searching, banging my head against the wall, trying dozens of solutions, it all comes down to a single line of code. I set this in the Browser static constructor so it's automatically executed whenever you use ABCWebTest. I didn't want to force all ABCWebTest.NET users to have to put this line into their NUnit tests.

Posted by Misha Rybalov at 11:50 AM | Comments (0)

April 26, 2006

Dealing with Frustrating Development Issues

So I was ready to continue ABCWebTest development today and implement some mouse automation into the product (very useful for testing Ajax web applications) but I kept running into the same error/exception when I ran my unit tests.

The details aren't important but if you must know (and there is a selfish side to this post to solicit help) I get a System.InvalidCastException when I try and obtain the "parentWindow" property from an MSHTML.IHTMLDocument2 object. Try as I might to work my way around it, I can't find a way to avoid this exception today.

The really frustrating thing is that this was working before! In previous days, there was no exception. I tried a few techniques to get past this blocker - I took a brief nap to come back with fresh eyes (no luck), I tried researching for a solution to this problem on the web (no luck), I tried reading other people's unrelated blogs to take a break from banging my head against the wall (no luck). So in the end, I decided it's better to stop banging my head against the wall, take my losses for the day and move on to other business activities.

Posted by Misha Rybalov at 11:34 AM | Comments (0)