Sunday, July 19, 2009

Verifying Email notifications

For long time, I was looking a solution to automate the verification of email contents. It required to verify for few user accounts, attachments like Excel, PowerPoint and PDF docs. We have few critical features, which required to verify email contents and attachments. Silktest does not have any built-in functions for this activity. However I have to find a solution. The solution should supports IE6 and IE7 browsers and Windows 2000, Windows XP and Vista OS. I had four choices in mind. They are,

  1. Using a command line utility
  2. Using MS Office Outlook COM interface
  3. Using Collaboration Data Objects (CDO) Interface with Outlook Express
  4. Worst case - Automate any email client with UI

Automate any email client with UI
This option was last one. Because I do not want to automate with User Interface. We can build the solution in couple of weeks effort. The issue is the changes with that client. I have to look on support for different Operating Systems such as Windows XP and Vista.

Using Collaboration Data Objects (CDO) with Outlook Express
In my first company, I have used CDO with Visual Basic. See my previous post - Checking Mail Notification. I got a surprise, while I was searching information for CDO Help. Microsoft has stopped the updates on Outlook Express. Earlier Internet Explorer Intallation was bundled with Outlook Express.

Using MS Office Outlook COM interface
I am familiar with VB script. I have used Outlook COM interface [CreateObject("Outlook.Application")] earlier. The issue is, the particular user account mailboxes should be opened, while executing VB Script. Also I thought the license and installation costs.

Using a command line utility
I have searched many times and found a utility. GetMail is a command line utility and it is working in all windows OS. It is available at GETMAIL for Windows It is a cheapest and best utility to fit for my requirements.

Different Cmdline switches of GetMail
Getmail has different switches for various purposes. You can opt appropriate switches as per your requirement.
 

GetMail v1.33: WinNT console utility to download a mailbox's mail.
syntax:
Getmail -u <user> -pw <password> -s <server> [optional switches (see below)]
Getmail -install [ see install details below ]
Getmail -profile [-delete | "<default>"] [profile1] [profileN] [-q]
Getmail -h [-q]
Getmail -forceextract filename

-install <server> <userid> <password> [<delete> [<xtract> [<try> [<port> [<profile>]]]]]
: set's POP3 server, login, password, whether to delete or not (Yes/No),
whether to automatically extract base64/7bit/UU encoded files or not (Yes/No),
number of tries and port for profile
(<delete> <xtract> <try> and <port> may be replaced by '-').

-u <userid> : Specify userid on remote pop3 host
-pw <password>: Specify password for userid on remote mail host
-s <server> : Specify mail server (pop3) to contact
-nodelete : Do not delete messages after downloading (default)
-delete : Delete messages after downloading
-noxtract : Do not extract base64/7bit/UU files after downloading (default)
-xtract [defname]: Extract base64/7bit/UU encoded files after downloading messages
defname is an optional default filename for the extracted file
-domainstamp : Prepend sender's domain name to extracted attachments
-headersonly : Download only the headers of the message
-port <port> : port to be used on the server, defaults to POP3 (110)
-p <profile> : send with SMTP server, user and port defined in <profile>.
-q : supresses *all* output.
-n <n> : Only get 'n' messages
-m <n> : Only get message # n
-b <n> : Retrieve messages beginning from # n
-plain : Extract text/plain segments too (usually ignored)
-h : displays this help.
-try <n times>: how many attempts to access mail. from '1' to 'INFINITE'
-ti <n> : Set timeout to 'n' seconds.
-forceextract fn: Attempt to extract any encoded messages in 'fn'

Installing GetMail
You need to follow the belows steps to install it. Assume that getmail.exe is stored under D:\tools.
  1. First open a command prompt.
  2. Go to D:\tools folder.
  3. Install it by executing below commmand
    Getmail -install mailserver script1@auto.com wrongpwd
    Here mailserver means the mail Server name or IP address

Verifying GetMail
To verify the GetMail installation, you can use following steps.
  1. Goto folder D:\tools
  2. Execute the following command for any user.
    For example, D:\tools\getmail.exe -u script1 -pw TestPassword -s mailserver
  3. Check any error exists on command prompt.
  4. Check on that folder, whether all the mails are downloaded or not. You can see mails like msg1.txt,msg2.txt,..etc

4Test code - To Verify the GetMail
 

[ ] sMailCommand = "{gsToolsDir}\getmail.exe -u {sUser} -pw {sPass} -s {sServer} {sAdditionalSwitch}"
[ ] Print ("Mail Command: {sMailCommand}")
[+] // if (bDeleteAfterReceive)
[ ] // sMailCommand = "{gsToolsDir}getmail.exe -u {sUser} -pw {sPass} -s {sServer} -delete"
[+] // else
[ ] // sMailCommand = "{gsToolsDir}getmail.exe -u {sUser} -pw {sPass} -s {sServer} -nodelete"
[ ] // Checking any errors on command line output
[+] if( 0 != SYS_Execute( sMailCommand, lsGetmailOut ) )
[ ] ListPrint( lsGetmailOut )
[ ] LogError ( "FAIL. Unable to receive the mail." )
[ ] return FALSE
[ ]

Sunday, July 12, 2009

Top 10 Silktest blogs/forums

Earlier I have seen Dmitry Motevich's post 15 QTP sites/blogs/groups/forums. Similarly I have listed for Silktest.

  1. SQA Forums
    Initially it was QAForums. Many silktest users are participating here. You can find many silktest expertise in this forum. It is having more than 50k posts and sample code.
  2. Borland Support
    Tool vendor's support site. Recently borland made compulsory service contract to access Knowledgebase articles and silktest community. It has plenty of usefull KB articles.
  3. Silktest FAQ & Tips
    Great blog for Silktest FAQ and tips. It has detailed solutions for common silktest issues.
  4. Silktest and Automation Tips
    Here user can find Silktest tips, code and automation tricks. Also covering advanced features of Silktest.
  5. Silktest tips
    One more good blog with limited posts.
  6. Silktest Yahoo groups
    It is the only active Silktest yahoo groups. One can find many expertise here.
  7. Silktest Tutorial
    Having detailed tutorials for Silktest.
  8. Silktest on QACampus
    Few more Silktest information is shared here.
  9. Darshan's blog
    Contains mixed of silktest and python posts.
  10. CSDN blog
    Many posts are in Chinese language. Has covered most of the silktest features.


Also I would like to mention few popular silktest sites, which are not available now. Many of you would have seen Bret Pettichord's Software Testing Hotlist. But most of the Silktest links are not exist today. All of them having fundamental and advanced concepts of Silktest. Also they have shared 4test sample code and white-papers.

Jeff Hemsley-OOPs and Classes concepts
Non-exist Link: http://www.weirdness.org/jeff/articles/a_classes.html
Current Page: Classes, Objects, Dynamic Instantiation and Constructors: Is 4Test Really an Object-Oriented Language?

Tony Venditti's Silk Automation Page
Non-exist Link: http://www.iris.com/web/irisdevs.nsf/c404f3f7c0cc20458525618c00633c15/f41c9c2b9b8dc4508525666700747f56?OpenDocument
Info about him: IBM page

Silktest White Papers - ameliortech
Non-exist Link: http://www.ameliortech.com/stuff/toolkits/ST/st_whpap.htm

4Test Hints and Tips
Non-exist Link: http://www.testmap.com/4test/4test_support.htm

Automation Expertise Tutorials
Non-exist Link: http://www.automationexpertise.com/Tutorials/SilkOrganizer/pages/Parent.htm

Mr. Cluey's Kludge Page
Non-exist Link: http://www.sqa-test.com/mr_cluey/

Automation on Quality Tree website
Non-exist Link: http://www.qualitytree.com/autotest/qapartner.htm

Automation Junkies
Non-exist Link: http://www.automationjunkies.com/resources/experts.shtml

I think that I can put them here, If I am able to retrieve those missed pages from my storage or from others. What do you say?

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)?