Skip to content

Instantly share code, notes, and snippets.

@daluu
Created February 13, 2012 05:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daluu/1813859 to your computer and use it in GitHub Desktop.
Save daluu/1813859 to your computer and use it in GitHub Desktop.
Silk4JLibrary design notes 1 for Robot Framework
The following are some notes on how to develop a Silk4J-based test library for Robot Framework to use the Borland Silk GUI automation tool/library.
Suggest use Silk4J GUI element/object location inline object model (identify object & execute automation all in one line of code):
desktop.<controlType>find("/windowHandleType[@caption='window title']//controlType[@automationId='idName']").commandName();
At the control type descriptor for automation ID, the automation ID is only the required first array index to locating the object/element. As I recall, there can be optional second index after it that further describes the object/element, but I forget it's syntax, but it goes like such of course:
...//controlType[@automationId='idName'][some other identification here]").commandName();
To make better use of inline method for API calls then, you can try to parameterize control type, window handle type, caption/window title/text, automation ID, and the automaton command into variables rather than as static text.
With the above method, I think you have to instantiate the desktop object but forget.
There is alternate object model where you use multiple lines of code as follows:
-----------------
//Have the "base" desktop object instantiated. Also have parsed arguments/parameters
//for window handle type, control type, automation ID, automation command
//and stored into variables for later use
switch(windowHandleType){
case Dialog:
//some common or not code
//will have some code that will expand to another switch/case
//or if/else branch to break down GUI object handling
//see next case...
case FormsWindow:
//some code - same or diff from other cases with
//eventual object creation to handle GUI object to automate
automationObject = desktop.FormsWindow("caption text");
//object is then used in inner branching
//and so on for other window handle types
}
//Now in the inner branching we have this:
switch(controlType){
case TextField:
//some common or not code
//here we have code that does stuff (GUI automation)
//see next case...
case PushButton:
if(command == "click"){
automationObject.PushButton(automationId).click();
}
//and so on for other control types
}
-----------------
From here, there are several window handle types, and many control types in Silk4J. See Silk4J API reference.
Given these models, you could perhaps build a generic automation API that calls the Silk4J automation methods, consolidating common functionality (so as not need to make a call to a specific method in Silk4J to click a button vs different Silk4J method to click checkbox), and where this API is used in some test tool or framework like Robot Framework.
The generic API then can abstract all the complex automation object details of Silk4J making it easier & friendlier to use by users like such:
genericApiObject.click(windowTitleOrHandle,controlType,automationId);
genericApiObject.type(windowTitleOrHandle,controlType,automationId,"some text to type");
where controlType is the object/element type, and automationId is the identifier to that specific element (especially in the case where there are multiple such elements on the screen)
and where windowTitleOrHandle gives you a reference to the application where the object/element resides, similar to how the free AutoIt automation tool works (it typically asks for window handle/text in addition to the control being manipulated).
if considering Robot Framework, once implemented correctly, the test library method call would look like follows (assume white space between text = column delimiter in Robot Framework test case, except for quoted text):
Type windowTitleOrHandle controlType automationId "some text to type"
For implementing Silk4J test library for Robot Framework, read these:
http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html?r=2.5.7#creating-test-libraries
http://code.google.com/p/robotframework/wiki/RemoteLibrary
http://code.google.com/p/jrobotremoteserver/
Now for gory details of Silk4J API classes and their methods that we're interested in for making a test library out of (not all the classes and methods are of interest).
import com.borland.silktest.jtf
Sorry ran out of time. This is where I list out relevant Silk4J APIs for building the library...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment