Category Archives

Test Automation

McWatin – can now open and close firefox by itself

With the latest commit to the repository can now open and close firefox all by itself. 🙂

The next feature to add is detection if a browser is open with jssh running and to re-use that browser instead of always launching a new one, or close as appropriate.

On thing that I have noticed is that the lack of a debugger in mono develop on the mac is really slowing me down as I can’t easily follow the code execution.

Test Automation Watin0 comments

Making progress on the WatiN mac os x port

So I haven’t worked on my WatiN Mac os x port for a few days, but I got back into it last night. The main hurdle at the moment is that the System.Diagnostics.Process class is not fully baked on Mono 2.4 on the Mac platform, because it doesn’t implement the /proc filesystem that linux does.

The correct thing to do would be to learn how the Mach kernel process structure works and fix mono, but I haven’t programmed in non managed C since 1990 and I would be very dangerous, especially at such a low level in mono.

So the first approach was to use the parts of mono that were working, namley Proces.Start() to call a shell script that I wrote to /tmp, then redirect standard out to a file, then parse that file and act accordingly.

StreamWriter sw = new StreamWriter("/tmp/",false);
sw.WriteLine (@"ps x | grep" + processname + " | grep -v grep > /tmp/watin-processlist.out");

<p>Process shScriptProcess = new Process();
shScriptProcess.StartInfo = new ProcessStartInfo(&quot;/bin/sh&quot;,&quot;/tmp/;);

A hack, yes, in fact a very messy hack. So messy there had to be a better way.

And there is …

Enter Monobjc. Monobjc is a managed wrapper around the Mac os x Cocoa API’s. A quick search pointed to the NSTask and NSPipe classes as a way to start a process with NSTask, and capture standard out with NSPipe, then parse the result.

A much more technically correct solution.

public static void Main(string[] args)
// spin up the objective-c runtime
NSAutoreleasePool pool = new NSAutoreleasePool();</p>

<p>// Create our process
NSTask task = new NSTask();
NSPipe standardOut = new NSPipe();
task.StandardOutput = standardOut;
task.LaunchPath = @&quot;/bin/ps&quot;;</p>

<p>// add some arguments
NSString argumentString = new NSString(&quot;-ax&quot;);
NSArray arguments = NSArray.ArrayWithObject(argumentString);
task.Arguments = arguments;</p>

<p>// We have liftoff

<p>// Parse the output and display it to the console
NSData output = standardOut.FileHandleForReading.ReadDataToEndOfFile;
NSString outString = new NSString(output,NSStringEncoding.NSUTF8StringEncoding);

<p>// Dipose our objects, gotta love reference counting

So this needs to be fully baked in and then put into my Watin on mac os x port and then it should work stand alone, without shell script assistance.

Test Automation Watin0 comments

Become a HTML testing ninja with the new Safari web inspector

The latest nightly builds of webkit, includes the new improved web inspector. It includes great new features such as:

  • A Javascript debugger
  • A Javascript profiler
  • A resources panel so you can find where your page takes time to load
  • Support to look into HTML 5 databases

For all the details check out the post here, then download your latest sword and get testing.

Advanced Testing Techniques Test Automation0 comments