WatiN COM Interface
To facilitate the use of WatiN with non-.NET languages, the COM interface to WatiN was born.
Usage of the interface closely resembles the assembly use, but there are a few significant places
where it had to differ, especially with static and overloaded methods.
Here is an example of C# to create a browser and search for WatiN on Google:
IE ie = new IE("http://www.google.com");
ie.TextField(Find.ByName("q")).TypeText("watin");
ie.Button(Find.ByName("btnG")).Click();
Now the same thing with PHP version 5.2 and the COM interface:
<?php
$iface=new COM("WatiN.COMInterface");
$ie = $iface->CreateIE("http://www.google.com");
$ie->TextField($iface->FindByName("q"))->TypeText("watin");
$ie->Button($iface->FindByName("btnG"))->Click();
?>
Differences to notice are:
- COM interface instantiation (of course)
- CreateIE method is new, along with the Attach object becoming AttachByUrl and AttachByName, all on the interface object
- Find object (a static method) becomes several methods of the interface object, like FindByName and FindById
- Overloading is not supported, so a single instance of the element descendant's method had to be chosen. In this case, using the FindByName method.
For now, documentation is non-existent (sorry).