Powered by discountASP.NET
referal ID: sdtref
Why recommend discountASP.NET?
$720 in referrals so far!

About/Contact

Steve Trefethen

Steve Trefethen is a Software Architect and Director of Software Training at Falafel Software in Capitola, CA. You can reach Steve here.

All opinions you read here are Steve's own and are not necessarily those of Falafel Software.

Calendar

<<  September 2010  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

View posts in large calendar

Disclaimer

The posts on this weblog are provided AS IS with no warranties, and confer no rights. The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
If you're new here, you may want to subscribe to my RSS feed, follow me on Twitter, or subscribe via email. Thanks for visiting!

TestComplete and automating dynamic JavaScript menus

August 13 2009 8:41AM

TestComplete Online TrainingIf you read my blog regularly you know I conduct TestComplete training where we teach people how to use the product and get the most out of their automation investment. One of the issues that comes up regularly is how to deal with dynamic content on web pages such as popup menus implemented using JavaScript. I’ve blogged before about automation being hard and when it comes to web applications and dynamic display of HTML driven by JavaScript the challenge can be quite steep particularly for someone first learning GUI automation.

Automating Web Applications

GUI automation for web applications can be very different than testing standard Windows applications and there are some tools and techniques that can really help to resolve these particular challenges. Let’s take a look at an example.

Let’s there’s a dynamic JavaScript menu control on your application like this:

 image

The challenge for a recorder with this example can be mouse hover behavior of the menu. Hovering the mouse over the menu items activates the submenus automatically and some recording tools don’t capture that information. TestComplete records selection of the Orders item as follows in JScript:

function Test1()
{
  var  iexplore;
  var  page;
  TestedApps.iexplore.Run(1, true);
  iexplore = Aliases.iexplore;
  page = iexplore.pageHttpTrainingFalafelComDynami;
  page.ToURL("http://training.falafel.com/dynamiccontent/");
  page.formForm1.panelMenu1n3items.table.cell.tableMenu16Menu115.cell.linkOrder.Click();
  //Please wait until download completes: "http://training.falafel.com/dynamiccontent/NewItem.aspx"
  iexplore.pageHttpTrainingFalafelComDynami1.Wait();
}

Playing back this recording results in error indicating that TestComplete was trying to click outside the bounds of an object which in this case happens to be the Orders item but since it never appears on screen it’s impossible to click on it at all. Fortunately, there is an alternative which is to write a function that will handle menu selection for any item within the menu control using a familiar syntax to address the menu items.

However, there’s the minor issue of understanding exactly what it takes to develop such a routine and that means digging into the HTML of the page and coming up with a mechanism to uniquely identify the various menu items. To aid this process I leverage the Internet Explorer Developer Toolbar or the Developer Tools add-in which allows us to dig into the page right from within IE. Let’s take a look:

If you examine the href property of the Customer menu item you can see that it contains a string that’s unique, ‘Add\\New\\Customer’. In fact, the entire menu hierarchy has a similar structure which means our routine could search for items with that attribute, hover the mouse over each subitem and finally click the Orders items. Of course, if you examine the Orders item its href will be an actual URL an not a JavaScript call so we’ll need to find that item using it’s innerText property. Ok, now let’s look at the code, which doesn’t include any error checking:

function AspNetMenuSelect(page, menuitem)
{
  var items = menuitem.split("|");
  var itemstr = "";
  var count = 0;
  while(count < items.length - 1)
  {
    itemstr = itemstr + items[count];
    item = page.NativeWebObject.Find("href", "*" + itemstr + "*", "a");
    itemstr = itemstr + "\\\\";   // Add\\New\\Customer
    item.HoverMouse();
    count++;
  }
  item = page.NativeWebObject.Find("innerText", items[count], "a");
  item.Click();
  page.Wait();
}

The function is called as follows:

AspNetMenuSelect(page, “Add|New|Customer|Order”);

Where “page” represents Sys.Process(“iexplore”).Page(“*”). If you’re not familiar with TestComplete it exposes a “Page” object off of Internet Explorer (and Firefox) allowing a test to access elements of a web page.

The second parameter is a “|” separated string of menu items to select. The code breaks the string up into an array, searches the page looking for an anchor tag that has an href with the specified value and hovers the mouse over it. The process then repeats, building up the href the value we identified above until the last parent menu item is reached. The final piece is to locate the last menu item using the innerText property, click on it then wait for a page load to complete.

If you have a test automation tool, any tool, go ahead and record this test case where you click on the item highlighted above using a non-journaling mode and see how well it plays back. Then, post a comment below and let me know the outcome I’d be really interested in seeing some of the other tools compare. I will note that Selenium had no problem recording this example though it uses an entirely different technique.

Admittedly, it’s not terribly satisfying when you record a test and your tool of choice fails to replay it properly, a situation that can understandably leave people frustrated. It’s important to grasp the limitations of your recording software as I’ve yet to find one that works flawlessly in all cases. However, in the case of TestComplete, through scripting, we can dig in at a lower level and solve problem.

imageNow, if you made it this far which I hope you did because you can watch a video of this whole process on Falafel Software’s new tv.falafel.com website here.

Ok, so that was a bit of tease… :-)

FacebookDel.icio.usDigg It!

Tags: , ,

GUI Test Automation with Ranorex Studio

March 25 2009 6:19AM

Today I got a demo of a tool called Ranorex Studio, a test automation product built using the SharpDevelop IDE. Aside from the IDE, I last played with in the early days of the SharpDevelop project, the most interesting aspect was the Ranorex C# framework with that provides the basis of modeling UI elements in a manner similar to Zombie’s GEM framework. Tests can be written in C#, VB.NET or Iron Python using the framework to build tests. To give you a taste of this kind of "model" binding here is fragment from a typed class that models Windows Calc:

/// <summary>
/// The FormCalculatorAppFolder folder.
/// </summary>
public class FormCalculatorAppFolder : RepoGenBaseFolder
{

    /// <summary>
    /// Creates a new FormCalculator  folder.
    /// </summary>
    public FormCalculatorAppFolder(RepoGenBaseFolder appFolder) : 
            base("FormCalculator", "/form[@title='Calculator' or @title='Rechner']", appFolder, 3000, true)
    {
    }

    /// <summary>
    /// The ButtonAsterisk item.
    /// </summary>
    public virtual Ranorex.Button ButtonAsterisk
    {
        get 
        { 
            return CreateAdapterForPath<Ranorex.Button>("ButtonAsterisk", "button[@text='*']", 5000, null);
        }
    }
    /// <summary>
    /// The Button3 item.
    /// </summary>
    public virtual Ranorex.Button Button3
    {
        get 
        { 
            return CreateAdapterForPath<Ranorex.Button>("Button3", "button[@text='3']", 5000, null);
        }
    }
    /// <summary>
    /// The ButtonEqual item.
    /// </summary>
    public virtual Ranorex.Button ButtonEqual
    {
        get 
        { 
            return CreateAdapterForPath<Ranorex.Button>("ButtonEqual", "button[@text='=']", 5000, null);
        }
    }
    /// <summary>
    /// The OutputText item.
    /// </summary>
    public virtual Ranorex.Text OutputText
    {
        get 
        { 
            return CreateAdapterForPath<Ranorex.Text>("OutputText", "text[@controlid='403']", 5000, null);
        }
    }
    /// <summary>
    /// The ButtonClose item.
    /// </summary>
    public virtual Ranorex.Button ButtonClose
    {
        get 
        { 
            return CreateAdapterForPath<Ranorex.Button>("ButtonClose", "titlebar/button[@accessiblename='Close' or @accessiblename='Schließen']", 5000, null);
        }
    }
    /// <summary>
    /// The Button7 item.
    /// </summary>
    public virtual Ranorex.Button Button7
    {
        get 
        { 
            return CreateAdapterForPath<Ranorex.Button>("Button7", "button[@text='7']", 5000, null);
        }
    }
    /// <summary>
    /// The ButtonMinus item.
    /// </summary>
    public virtual Ranorex.Button ButtonMinus
    {
        get 
        { 
            return CreateAdapterForPath<Ranorex.Button>("ButtonMinus", "button[@text='-']", 5000, null);
        }
    }
    /// <summary>
    /// The Self item.
    /// </summary>
    public virtual Ranorex.Form Self
    {
        get 
        { 
            return CreateAdapterForPath<Ranorex.Form>("Self", "", 3000, null);
        }
    }

    
}

Notice in this example methods of class FormCalculatorAppFolder use XPATH regular expressions to “bind” their respective UI element which I think this is an interesting approach with a lot of flexibility. Also notice the idea here is similar to that of strongly typed dataset for data access. The tool provides a set of “adapters” which are used to drive various types of UI at varying degrees of accessibility (WinAPI, .NET, Web, MSAA).

I haven’t had enough time using the tool or framework to draw a conclusion as to the validity of the approach or quality of implementation but I have seen a few unexpected error dialogs which are things that will need to be fixed right away.

Are you familiar with or have you used this tool? If so, what do you think?

If not, what tools are you using for GUI automation?

FacebookDel.icio.usDigg It!

Tags: , ,

Adding a project to TFS from TestComplete

February 06 2009 4:10PM

TestComplete Online TrainingAs a TestComplete trainer I’ve found myself re-installing it a few times and I typically have to reconfigure my TFS connection. I’ve been asked about this a few times so I thought I’d write it down. Here are the steps to setup and add a TestComplete project to TFS.

  1. Select Tools | Issue Tracking | Connection Manager. This is usually the step I forget since it seems a bit odd to got to Issue Tracking when I want Source Control. Anyhoo…

    TestComplete Connection Manager
  2. Click Add…, provide a Connection name and select Visual Studio Team System:

    TestComplete Connection Wizard
  3. Click Next and specify the TFS URL and credentials:

     TestComplete Connection Wizard Team System
  4. At this point, you should see the status of the connection and the top-level projects from the TFS server:

     TestComplete Connection Wizard
  5. Now, from the Project Explorer you can right click your Project Suite and add it to the repository:

    Adding a TestComplete Suite to TFS

And that as they say is it.

Are you using TFS? Do you use it in TestComplete?

FacebookDel.icio.usDigg It!

Tags: ,

Command line alternatives to Remote Desktop

December 30 2008 5:14PM
Most days I’m connected to a client’s VPN working on a project and lately I’ve converted from using Remote Desktop (RD), Terminals actually and highly recommended btw, to psexec and taskkill to get things done. Using psexec I start/stop CCService, run CCNET from the console, use SVN and build from the command line to name a few. The machine I connect to most of the time has a limited simultaneous RD users and occasionally I’m unable to get a connection so having an alternative is crucial. One caveat I ran into was TortoiseProc.exe fails to terminate when run remotely with psexec and has to be killed manually and unfortunately the SVN command line tools are not installed, at least not yet. Occasionally, I use remote.exe from the NT Resource Toolkit though I haven’t used that in quite awhile not to mention the EXE I have is from 1997, not that that makes it any less effective.

Do you do something similar? What utilities do you use?

[Update: Feb 23, 2009] I also use psloggedon which is useful to see who is using the machine. Additionally, it’s nice to be able to launch a console window on the remote machine as well like this (though as Bary notes below ssh is also an option):

psexec.exe \\machine -w d:\ cmd.exe

FacebookDel.icio.usDigg It!

Tags:

Virtual desktop software VirtuaWin

August 11 2008 5:09AM

In a recent post, I talked about the various applications I use while conducting online training. Over the years I’ve dabbled with virtual desktop software but never got very comfortable with the idea and thus it never "stuck". Back in June I decided, once again, to look for virtual desktop software and one of my first searches lead me to this description which looked very promising:

VirtuaWin is a small, fast and easy to use virtual desktop manager for Windows9x/ME/NT/2000/XP with no unnecessary features.

Bingo! Exactly the kind of thing I was looking for and VirtuaWin has lived up to this description. While the above description doesn’t explicitly mention Vista I’ve had no problems (I wish I could say the same about Vista). I’ve been running it now for a month and a half and it’s worked pretty darn well. The current release is 4.0.1 from April of this year so it’s an Open Source project that’s very much alive and well. On of the best features is worked "out-of-the-box" and I’ve tweaked only a few settings so the overall experience as been very good.

At first, it took some time to get used to organizing multiple desktops but once acclimated having the extra space has been very nice. I use four desktops arranged horizontally with the first being my primary, one to the left for browsers, one to the right for email and fourth desktop for things like LaunchCAST for streaming music. My MacBook Pro runs at 1920x1200 and I use a second 20" monitor running at 1600x1200 brining my virtual desktop size to a whopping 14,000x1200, although when connected to a second monitor I usually don’t use the virtual desktops much.

On thing I’ve discovered is that virtual desktops also work quite well for online training making it easy to switch between PowerPoint presentation and the application I’m training on. I guess you could call it an online version of a KVM switch!

FacebookDel.icio.usDigg It!

Tags: ,

For me Google Reader just gained some serious competition in feedly

June 24 2008 5:12AM

If you haven’t checked out feedly and you’re a blog/RSS reader you definitely should. It’s a Firefox 3.0 plugin that has some really cool features and turns your feeds into a magazine style web page.

[Updated: June 24, 2008] I should mention that this is really functioning as an alternative UI for Google Reader rather than a replacement since it updates Google Reader as I'm reading items.

 feedly Firefox plugin

FacebookDel.icio.usDigg It!

Tags:

SQL Server Index Nightmare

June 18 2008 6:21AM

The other day I discovered one of the MSSQL tables I’m using heavily at the moment had 214 indices! There were about 20 with sensible names and the rest were all named similar to _dta_index_SA_OrderHeader_5_499519046__K1_2_6_9_13. I mentioned this issue to John Waters in the office today which elicited a nice laugh until I sent him this screenshot:

SQL Manager 2008 Lite

While I’m not exactly new to MSSQL I’m no expert though fortunately Falafel has a few experts on staff and John’s one of them. He dug into the problem answering the what, where and how to deal them, feel free to click through if that’s what you need.

Had I not blogged back in February asking about MSSQL tools this problem would likely have gone undetected for a lot longer. Microsoft’s Management Studio doesn’t show these so called Hypothetical Indices so you have no way of knowing your table/DB is being impacted by them. Ironically, they’re created by the Index Tuning Wizard. Anyway, one commenter to my post mentioned EMS Database Management Solutions (a mouthful notwithstanding whatever EMS stands for) SQL Manager 2008 for which there is a freeware download. SQL Manager’s treeview provides a wealth of information including counts for things like indices which allowed me to easily stumble upon the problem.

All in all, there were 500+ of these indices hanging around but thanks to SQL Manager no longer!

FacebookDel.icio.usDigg It!

Tags: ,