Showing posts with label silk4j. Show all posts
Showing posts with label silk4j. Show all posts

Monday, October 19, 2009

Silk4Com

Silk4com is a COM interface for open agent. Still it is under development. It is an open source project and hosted on google code pages. I would say, it is an innovative idea.

URL: Silk4Com Project page

Summary from Project page
"This project is an add-on for SilkTest 2009. The goal of this project is to provide a COM interface for the Open Agent, which can be used by many different scripting languages to drive the Open Agent. With silk4com you can use most of the JTF API in VBScript, JavaScript or even in VBA, without the need of a Java Compiler and JUnit. "

I tried a sample script and it works fine.
VBS Code with Silk4Com

Sub SimpleTestcase2(browser) Set searchField = browser.Find("//input[@name='q']") searchField.hugo = "asd" WScript.Echo(searchField.hugo) '' Added by Palani searchField.setText("silk4j tutorial") Set btn = browser.find(".//input[@type='submit' and @name='btnG']") 'Set btn = browser.find(".//DomButton[@type='submit' and @name='btnG']") ''Not working btn.click() End Sub
Silk4j Code
@Test public void testSimpleGoogleSearch() throws Exception { // DomTextField[@title='Google Search' and @maxLength='2048' and @size='55' and @name='q' and @autocomplete='off'] DomTextField searchText = (DomTextField)browser.find (".//DomTextField[@title='Google Search' and @name='q']"); searchText.setText(""); searchText.setText("silk4j tutorial"); DomButton btn = (DomButton)browser.find( ".//DomButton[@type='submit' and @name='btnG']"); btn.click(); }

Sunday, August 16, 2009

Silktest 2009

Recently MicroFocus released Silktest 2009. In this release, Silktest has many enhancements for Open Agent and Eclipse Plugin.

Silktest 2009 Page on MicroFocus
Silktest 2009 - Release Notes
Silktest - Supporting documents

New in Silktest 2009

  • AJAX Testing with xBrowser
  • Support for Recording Testcases that Use Dynamic Object Recognition
  • Silk4J Eclipse Plugin
  • New Basic Workflow for Applications that Use the Open Agent
  • Dynamic Object Recognition Supports Locator Keywords
  • The Open Agent Supports Windows Forms Applications
  • Enhancements in the XPath Syntax
  • AnyWin Class Includes Several New Functions and Methods
  • SWTTree Class Includes Several New Functions
  • Several SYS Functions are Supported on the Open Agent
  • SilkTest Recorder

Sunday, July 5, 2009

Silk4J Overview & Analysis

Silk4j was introduced from Silktest 2008. Hereafter user can use Java as test scripting language with the help of Silk4J Package. It is supported only with Open Agent. I hope that Borland might target developers too. User can write java unit tests as well as GUI tests.

From Silktest Help - Silk4J Eclipse Plugin

Silk4J enables user to create functional tests using the Java programming language. Silk4J provides a Java runtime library that includes test classes for all the classes that Silk4J supports for testing. This runtime library is compatible with JUnit, which means you can leverage the JUnit infrastructure and run and create tests using JUnit. You can also use all available Java libraries in your testcases.

The testing environments that Silk4J supports include:

  • Adobe Flex applications
  • Java SWT applications
  • Windows Presentation Foundation (WPF) applications
  • Windows API-based client/server applications
  • xBrowser applications


Silk4J with Open Agent - Google Search testcase

I have gone through documents such as Silk4J_QuickStartGuide_en.pdf and Silk4J_AdvancedUserGuide_en.pdf. I created the sample code and it works fine.

package com.palani;
import org.junit.Before;
import org.junit.Test;

import com.borland.silktest.jtf.Desktop;
import com.borland.silktest.jtf.TechDomain;
import com.borland.silktest.jtf.xbrowser.BrowserWindow;
import com.borland.silktest.jtf.xbrowser.DomButton;
import com.borland.silktest.jtf.xbrowser.DomTextField;

public class GoogleSearch {
private Desktop desktop = new Desktop();
private BrowserWindow browser;

@Before
public void setUp() throws Exception {

browser = (BrowserWindow)desktop.executeBaseState(
"C:/Program Files/Internet Explorer/iexplore.exe", null, null,
".//BrowserWindow", TechDomain.XBROWSER);
browser.navigate("http://www.google.co.in/");
}

@Test
public void testSimpleGoogleSearch() throws Exception {

DomTextField searchText = (DomTextField)browser.find (".//DomTextField[@title='Google Search' and @name='q']");
searchText.setText("");
searchText.setText("silk4j tutorial");
DomButton btn = (DomButton)browser.find(
".//DomButton[@type='submit' and @name='btnG']");
btn.click();
}
}


4Test with Open Agent - Google Search testcase
The same case is written in 4Test. SilkTest supports a subset of the XPath query language. It gives dynamic object recognition.

[ ]
[-] testcase GoogleSearch1 () appstate none //DefaultBaseState
[ ] STRING sUrl="http://www.google.co.in/"
[ ]
[-] if (! InternetExplorer.Exists(2))
[ ] InternetExplorer.Invoke ()
[ ] InternetExplorer.SetActive ()
[ ] InternetExplorer.Maximize ()
[ ]
[ ] WINDOW wMain = Desktop.Find(".//BrowserApplication")
[ ] WINDOW wBrowser = wMain.Find(".//BrowserWindow")
[ ]
[ ] wMain.SetActive()
[ ] wBrowser.Navigate (sUrl)
[ ] WINDOW wText1=wBrowser.Find(".//DomTextField[@title='Google Search' and @name='q']")
[ ] wText1.SetText("Silk4j Tutorial")
[ ] wBrowser.Find(".//DomButton[@name='btnG' ]").Click ()
[ ]
[ ] WINDOW wText2=wBrowser.Find(".//DomTextField[@name='q']")
[ ] wText2.SetText("Silktest Extension Kit")
[ ] wBrowser.Find(".//DomButton[@name='btnG' ]").Click ()
[ ]
[ ]


Selenium RC Java format - Google Search testcase

Selenium is a open source tool and can be used only web based applications. But user can choose different languages to develop the suite. Selenium tests can be written with Selenese, PHP, Perl, Python, Ruby, DotNet and Java.

import org.openqa.selenium.server.SeleniumServerTest;
import com.thoughtworks.selenium.*;
import junit.framework.*;
import org.openqa.selenium.server.SeleniumServer;

public class TestSearch extends SeleniumServerTest {
private Selenium browser;
public void setUp() throws Exception {
SeleniumServer seleniumServer = new SeleniumServer();
browser = new DefaultSelenium("localhost", 5555, "*firefox", "http://www.google.com");
seleniumServer.start();
browser.start();
}

public void testGoogle() {
browser.open("/webhp?hl=en");
browser.type("q", "hello world");
browser.click("btnG");
browser.waitForPageToLoad("5000");
assertEquals("hello world - Google Search", browser.getTitle());
}

public void tearDown() {
browser.stop();
}
}


Few Questions

Now Silktest and selenium both supports in Java language. Silktest supports many type of applications. In other end, Selenium supports many Operating Systems and browsers. I have few questions on Silk4J.
  1. Can Silk4J utilize silktest features such as TestcaseEnter,TestcaseExit,scriptEnter and ScriptExit?
  2. Target audience?
  3. Any Success stories (implementations)?