Test Run Q&A: Test automation

This post represents the beginning of a little experiment: we’re going to post questions directed to our column authors via the column e-mail aliases, and let you take part in the conversation. Our authors will answer as they are available, and we encourage you to chime in with questions or comments as well.

We start off with a question to Dr. James McCaffrey about AJAX test automation from his February 2007 Test Run column.

Hi James,

I just read your article on http://msdn.microsoft.com/msdnmag/issues/07/02/TestRun/ but I prefer coding in C# over coding in JavaScript. Would it be possible to perform similar tests using web-browser component of .NET Framework?

And if this is possible what are the benefits of JavaScript testing you showed on MSDN over web-browser component?



You can get more Test Run insight in the MSDN Magazine archives, or subscribe to the RSS feed for notification of new columns.


Technorati Tags: , ,
Comments (2)

  1. James McCaffrey says:


    Your first question — can you use C# instead of JavaScript to perform AJAX Web app UI testing through the IE Document Object Model — is one I often hear. The short answer is, unfortunately, no. Let me explain briefly. When you perform Web UI automation as I described in the Feb. ’07 issue of MSDN Magazine, you are writing client-side JavaScript code embedded in a Web page in one frame to manipulate the Web app under test which resides in a second frame:

    <script language="JavaScript">

    // automation code here that accesses the IE DOM


    So, in essence Internet Explorer is hosting your test script and indirectly interpreting and executing that code via your host machine’s scripting engine. However, C# is really a compiled language and IE cannot interpret C# on the client side. It would be very cool if, sometime in the future, the IE team enables some form of C# interpreter, but for now the only two languages I am aware of which can manipulate the IE DOM are JavaScript and VBScript.

    Your second question — if you can use client-side C#, what are the advantages of JavaScript — becomes moot.

    In the big picture, no single programming language is optimal for all tasks. This is true for software test automation too. But based on my experience, depending on my testing scenario, I most often use C#, JavasCript, and PowerShell.

    James M