3, 2, 1, zero ... All engines running. Lift-off! We have a lift-off.

I am happy to announce Open Twebst, open source web testing and automation framework!
http://open-twebst.codecentrix.com/
Get it while it's hot!
Happy web automation to y'all!
Twebst Automation Studio: browser macros, web scraping, web testing and automation for Internet Explorer.

// Create core object.
var core = new ActiveXObject("Twebst.Core");
// Find a browser for which the displayed URL contains "google.com".
core.useRegExp = true;
var b = core.FindBrowser("url=.*google.com");
b.Close();There are more Twebst methods for automating IE7 and IE8 tabs that I'll talk about in future articles: OpenNewTab, activeTab, isTabActive, tabList
.
' Don't forget to add reference to TwebstLib from menu Tools/References
Dim core As TwebstLib.ICoreVba
Set core = New TwebstLib.core
Dim browser As TwebstLib.IBrowserVba
Set browser = core.StartBrowserVba("http://www.google.com/")
For i = 1 To 5
' Get the current text to be translated
Dim textToTranslate As String
textToTranslate = ActiveSheet.Cells(i, 1).Formula
' Twebst web automation part
Call browser.Navigate("http://www.google.com/language_tools?hl=en")
Call browser.FindElementVba("textarea", "id=source").InputText(textToTranslate)
Call browser.FindElementVba("select", "name=sl").Select("English")
Call browser.FindElementVba("select", "name=tl").Select("French")
Call browser.FindElementVba("input submit", "text=Translate").Click
' Find result span object
Dim resultObj As TwebstLib.IElementVba
Set resultObj = browser.FindElementVba("span", "id=result_box")
' Get the text result
Dim translatedText As String
translatedText = resultObj.Text
' Save the result into Excel sheet
ActiveSheet.Cells(i, 2).Formula = translatedText
Next
That's all for now. Until our next encounter, check the download section below and have fun with the Excel VBA macro code.
Downloads:
Let's see some code. I will skip the initial setup phase and go directly to web automation part which is more interesting:
for (var i = 1; i <= 5; ++i)
{
// Get current text to translate from XLS document.
var textToTranslate = excelApp.ActiveSheet.Cells(i, 1).Formula;
// Web automation part implemented with Twebst Automatio Studio.
browser.Navigate('http://www.google.com/language_tools?hl=en');
browser.FindElement('textarea', 'id=source').InputText(textToTranslate);
browser.FindElement('select', 'name=sl').Select('English');
browser.FindElement('select', 'name=tl').Select('French');
browser.FindElement('input submit', 'text=Translate').Click();
// Get the reszult and save it into XLS document.
var translatedText = browser.FindElement('span', 'id=result_box').text;
excelApp.ActiveSheet.Cells(i, 2).Formula = translatedText;
}
Points of interest:
Downloads:

The WSH web macro in this tutorial opens an XLS file containing phrases to be translated using Google Translate tool. It then automatically gets each phrase, opens an IE browser, navigates to translation page, fills out the text to be translated, press submit button, gets back the result and saves it into the same XLS file.
That's all for now! (as I try to keep articles relatively short) Meanwhile, you should download Twebst Automation Studio and the web macro sample to see it at work. Then, you can continue with the next article explaining the web macro code and comments: Extract web data into Excel.Application with browser macro
Downloads:
Twebst Automation Studio (FREE edition available btw)
// Create core object.
var core = new ActiveXObject("Twebst.Core");
// Find a browser for which the displayed URL contains "yahoo".
core.useRegExp = true;
var b1 = core.FindBrowser("url=.*yahoo.*");
b1.Navigate("www.google.com");
// Find a browser for which the title is "Google" (exact match).
core.useRegExp = false;
var b2 = core.FindBrowser("title=Google");
b2.Close();Basically FindBrowser method searches for a browser page based on TITLE and/or URL. If core.useRegExp is false then an exact search is used. If core.useRegExp is true then the search uses regular expressions. Once connected to a IE browser instance, you get a Browser object to play with.
Of course, this works for IE6, IE7, IE8 on Windows XP, Vista and Windows 7 (32 and 64 bit) and it's compatible with Internet Explorer Protected Mode.
What can you do with a Browser object? Quite a lot of things: Navigate to a URL, FindElement and FindFrame inside it, Close the browser, get information about the browser, automate modal and modeless HTML dialgos and wait to complete navigation and loading.
Enough talk! It's time to Download Twebst Automation Studio and see it for yourself.
.
Dim core
Dim browser
Set core = CreateObject("Twebst.Core")
Set browser = core.StartBrowser("http://www.google.com/")
Call browser.FindElement("input text", "name=q").InputText("codecentrix")
Call browser.FindElement("input submit", "name=btnG").Click()
What is so great about the code above is the way FindElement method works: first it waits for the browser to load the HTML document then it searches for the element thru all frame/iframe hierarchy.Once an Element is found you can perform actions on it like: Click, RightClick, InputText, Check, Uncheck, Select, Highlight etc. What is even cooler than this, is that you don't have to write these statements by yourself. They will be automatically generated by Twebst Web Recorder which you can get for free:
Get Free Web Recorder for Internet Explorer
.
var core = new ActiveXObject('Twebst.Core');
var browser = core.StartBrowser('http://www.google.com/');The code is quite self-explaining. It creates a Twebst object and then opens a given URL in a new IE browser instance. What you get back from StartBrowser call is a Browser object that can be used to further automate Internet Explorer.
Option Explicit
Dim core
Dim browser
Set core = CreateObject("Twebst.Core")
Set browser = core.StartBrowser("http://www.2shared.com/")
Call browser.FindElement("input file", "id=upField").InputText("C:\somepath\photo1.jpg")After several months of complete radio silence, things have been moving forward for Twebst Library which turned into a more powerful and mature product.
Please welcome Twebst Web Automation Studio!
Twebst Automation Studio is an advanced web automation framework for Internet Explorer that can be used within any environment that supports COM, from scripting languages (JScript, VBScript) to high level programming languages (C#, VB.Net, C++).
The framework includes two components: Twebst Web Recorder that automatically generates most of the automation code and Twebst Library which is a collection of programable objects that creates a web automation API.
But one image is better than thousand words...
Twebst Web Recorder features:
Enough talk! Let the code speak for itself.
// Start a new Internet Explorer instance and navigate to a given URL.
IBrowserPtr pBrowser = pCore->StartBrowser("http://www.google.com/");
// Find search edit box in page and type some text into it.
IElementPtr pSearchEdit = pBrowser->FindElement("input text", SearchCondition("name=q"));
pSearchEdit->InputText("codecentrix");
// Find search button and click it.
IElementPtr pSearchBtn = pBrowser->FindElement("input submit", SearchCondition("text=Google Search"));
pSearchBtn->Click();
// Find the DIV element where the result are displayed.
IElementPtr pResultDiv = pBrowser->FindElement("div", SearchCondition("id=res"));
// Get all found results and print them in console.
IElementListPtr pResultList = pResultDiv->FindAllElements("h3", SearchCondition());
// Display only the header result (text and url).
for (int i = 0; i < pResultList->length; ++i)
{
// Get current H3 in the list.
IElementPtr pCrntResult = pResultList->Getitem(i);
// Find first and only anchor inside H3
IElementPtr pCrntAnchor = pCrntResult->FindElement("a", SearchCondition());
CComQIPtr<IHTMLAnchorElement> spCrntAnchor = pCrntAnchor->nativeElement;
// Get URL from IHTMLAnchorElement.
CComBSTR bstrURL = "";
spCrntAnchor->get_href(&bstrURL);
// Display results.
wcout << pCrntResult->text << L"\n" << bstrURL.m_str << L"\n\n";
}
// Open a browser and navigate to yahoo mail login page.
var core = new ActiveXObject("Twebst.Core");
var browser = core.StartBrowser("https://login.yahoo.com/config/mail?.intl=us");
// Find login fields.
var u = browser.FindElement("input text");
var p = browser.FindElement("input password");
var s = browser.FindElement("input submit");
// Log on to site by filling the user-name and password fileds and then click submit boutton.
u.InputText("UUUUUUUUUU");
p.InputText("PPPPPPPPPP");
s.Click();
It goes like this:
XML + JScript-> XML with color syntax and cross references + XSL -> HTML + CSS -> CHM
For local help, the CHM compiler is invoked as a final step and a CHM Help File is generated. All you have to do is launching Build.js script you may find in the archive below.
Downloads: TwebstHelp.zip
Prerequisites: In order to build the CHM file you'll need HTML Help Workshop from Microsoft.
using System.Runtime.InteropServices;
[DllImport("user32.dll")]
private static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vk);