Official website

Harness is Internet Explorer Automation Library.

Harness, we have implemented as a COM object. Can interoperate from COM, you can easily use from your favorite development language.

C#, JavaScript(JScript), VisualBasic, PowerShell, Python, Perl...

overview.png

powershell.jpg

C#

dynamic harness = Activator.CreateInstance(Type.GetTypeFromProgID("Harness"));

harness.Command("close", "all");
harness.Command("newBrowser", "http://www.yahoo.com", "-private");
harness.Command("set", "name=p", "harness");
harness.Command("click", "button=Search");

Visual Studio Unit Test (C#)

[TestMethod()]
public void YahooSearchTest()
{
    dynamic harness = Activator.CreateInstance(Type.GetTypeFromProgID("Harness"));

    harness.Command("close", "all");
    SHDocVw.InternetExplorer ie = harness.Command("newBrowser", "http://www.yahoo.com", "-private");

    Assert.AreEqual(ie.Document.Title, "Yahoo!");

    harness.Command("set", "name=p", "harness");
    harness.Command("click", "button=Search");

    Assert.IsTrue(ie.LocationURL.StartsWith("http://search.yahoo.com"));
}

JavaScript (JScript on Windows Script Host)

example of JScript "sample01.js"
var harness = new ActiveXObject("Harness");

harness.Command("close", "all");
harness.Command("newBrowser", "http://www.yahoo.com", "-private");
harness.Command("set", "name=p", "harness")
harness.Command("click", "button=Search")
Run "sample01.js" on Command Prompt
cscript.exe sample01.js

Visual Basic (VBS on WSH)

Dim harness
Set harness = CreateObject("Harness")

harness.Command "close", "all" 
harness.Command "newBrowser","http://www.yahoo.com", "-private"
harness.Command "set", "name=p", "harness"
harness.Command "clicK", "button=Search"

PowerShell

example "sample01.ps1"
$harness = new-object -comobject Harness

$harness.Command("close", "all" )
$harness.Command("newBrowser","http://www.yahoo.com", "-private")
$harness.Command("set", "name=p", "foo")
$harness.Command("clicK", "button=Search")
Run "sample01.ps1" on PowerShell (use -STA option)
powershell.exe -sta -command .\sample01.ps1

Python

import win32com.client

harness = win32com.client.Dispatch("Harness")

harness.Command("close", "all");
harness.Command("newBrowser","http://www.yahoo.com", "-private")
harness.Command("set", "name=p", "foo")
harness.Command("clicK", "button=Search")

Last edited Aug 28, 2012 at 4:03 PM by iHarness, version 48