Software Development Magazine - Project Management, Programming, Software Testing |
Scrum Expert - Articles, tools, videos, news and other resources on Agile, Scrum and Kanban |
Open Twebst - Open Source Web Automation for Internet Explorer
Adrian Dorache, CodeCentrix, http://www.codecentrix.com/
Open Twebst is an open source web automation framework for Internet Explorer browser that can be used within any environment that supports COM, from scripting languages JScript, VBScript to high level programming languages C#, VB.Net, VBA/Excel, Python, C++.
The framework includes two components: Open Twebst Web Recorder that automatically generates most of the IE automation code and Open Twebst Library which is a collection of programmable objects that creates a web automation API.
Web site: http://www.codecentrix.com/
Current version: 1.1
System requirements: Windows XP, Windows Vista, Windows 7 + IE 6.0 - 9.0
License & Pricing: open source, GPL v3 (http://www.gnu.org/licenses/gpl-3.0.html)
Support: for programming and features related questions about the product we strongly encourage you to use Twebst Google Group at: https://groups.google.com/forum/#!forum/twebst-automation-studio
Installation: the installation runs smoothly through a NSIS installer.
Documentation: http://codecentrix.com/doc/index.htm (the setup comes with a CHM help file as well).
Features:
- Start new IE browsers and navigate to a specified URL.
- Connect to existing browsers.
- Get full programmatic control over HTML elements and frames.
- Intuitive names for HTML elements using the text that appears on the screen.
- Advanced search of browsers and HTML elements using wildcards.
- Perform actions on all HTML controls (button, combo-box, list-box, edit-box, upload control).
- Simulates user behavior generating hardware or browser events.
- Get access to native interfaces exposed by Internet Explorer so you don't need to learn new things if you already know IE web programming.
- Synchronize web actions and navigation by waiting the page to complete in a specified timeout.
- Available from any programming/scripting language that supports COM
- Optimized search methods and collections.
- Easily create web macros through an intuitive graphical interface.
- Generate web automation code using the language of your choice: Python, JScript, VBScript, C#, VB.Net, Watir.
- Record web actions on all HTML web controls (anchor, button, combo-box, list-box, edit-box)
You can create a script simply recording your actions on the web page. Here is a picture of Open Twebst Web Recorder generating JScript code:
Code sample:
var
core = new ActiveXObject('OpenTwebst.Core');var
browser = core.StartBrowser('http://mail.yahoo.com/');browser.FindElement(
'input text', 'id=username').InputText('codecentrix');browser.FindElement(
'input password', 'id=passwd').InputText('1234');browser.FindElement(
'button', 'id=.save').Click();The script above automates the login page on Yahoo email web site. First we need a Core object to start a new Browser. Once we have the browser object we can search for HTML objects inside the web page.
FindElement method waits the page to be completely loaded before searching the DOM. Its behavior can be customized using several properties like: loadTimeout, searchTimeout and loadTimeoutIsError.
Once we have the Element, we can perform actions on it like: Click, InputText, Select. These automation methods simulate user actions generating all the relevant HTML events on target object.
Random facts:
Open Twebst Library contains only 5 types of objects: Core, Browser, Frame, Element and ElementList.
Open Twebst Web Recorder supports the following languages: VBScript, JScript, C#, VB.Net, Python and Watir.
While looking for HTML objects inside DOM, the whole frame/iframe hierarchy is taken into account. It works even for frames/iframes loaded from different domains bypassing cross domain security restrictions.
It can automate pop-ups and HTML modal/modeless dialog boxes. See: ClosePrompt, ClosePopup, FindModelessHtmlDialog and FindModalHtmlDialog.
You can gain access to native IHTMLElement and IWebBrowser2 objects exposed by IE using nativeElement and nativeBrowser properties.
You can attach to existing IE browser and even IE web browser controls embedded in other applications using FindBrowser method.
Wildcards can be used when searching for HTML objects in the web page. See: Search Conditions.
It works with all Internet Explorer versions from 6.0 to 9.0 + support for protected mode.
More Software Testing Content
Click here to view the complete list of tools reviews
This article was originally published in the Fall 2012 issue of Methods & Tools
Methods & Tools Testmatick.com Software Testing Magazine The Scrum Expert |