February 08, 2008
Tip10 - Get TimeStamp for Current time
It will be useful to create unique files and set the dateTime info whenever needed. Following code snippet will prepare timestamp based on that time.
[+] String GetTimeStamp()
//Purpose: To get current time stamp in the given format
String sDate, sTime
String sTcFile
STRING sPrefix
GetCurrentDateTime (sDate, sTime,"yyyymmdd","hhnnss" )
sPrefix = "{sDate}{sTime}"
return sPrefix
[+] public void GetCurrentDateTime(out String sDate optional, out String sTime optional,String sDateFormat null optional,String sTimeFormat optional)
// Purpose: Current date and time are taken from the system.
DateTime dtmCurrent
[+] if (IsNull(sDateFormat))
sDateFormat = "mm/dd/yyyy"
[+] if (IsNull (sTimeFormat))
sTimeFormat = "hh:nn:ss AM/PM"
dtmCurrent = GetDateTime ( )
sTime=FormatDateTime (dtmCurrent, sTimeFormat)
sDate=FormatDateTime (dtmCurrent, sDateFormat)
Tip9 - Two window panes same caption or title
If two window objects are unique, then look for unique child objects and re-define your frame like below. It will be useful mainly for web applications. Often the browser title will be same for many screens.
Assume that X & Y are two different windows and having same tag. Both windows are differentiated by their unique child objects.
Window X
tag "TestWindow/[TextField]Name/.."
Window Y
tag "TestWindow/[Pushbutton]Search/.."
February 07, 2008
Tip8 - To Repair IE6
Few times, IE DLLs may get corrupt due to silktest or some other thrid party tools. By this, silktest may not able to get browser objects properly. To repair IE,
Re-Install
Start > Run rundll32 setupwbv.dll,IE6Maintenance "C:\Program Files\Internet Explorer\Setup\SETUP.EXE" /g
or
Start > Run rundll32.exe setupapi,InstallHinfSection DefaultInstall 132 C:\windows\inf\ie.inf
and select to repair IE if this does not help.... then another possibility would be to run the LSP fix in Internet Explorer
http://inetexplorer.mvps.org/data/lsp_fix.htm
Re-Register DLLs
Another way is, copy below info into a batch file and run it.
REM Ie6_cure.bat
regsvr32 Shdocvw.dll
regsvr32 Shell32.dll
regsvr32 Oleaut32.dll
regsvr32 Actxprxy.dll
regsvr32 Mshtml.dll
regsvr32 Urlmon.dll
Tip7 - Unable to start Internet Explorer 6 DOM
It is a common problem. I have got this problem couple of times and rectified. Sometimes, we may get like below,
---------------------------
Extension Settings
---------------------------
SilkTest detected a Client/Server application.
The required Extension has been enabled.
---------------------------
Problem Cause
Few Silktest DLLs got corrupted for that profile (Say primary user). Thats why it is throwing that error.
Solution
In that same machine, login as other user and run the same scripts.
If it works fine, delete your primary user profile -> restart the machine-> login as the same primary user. Than the scripts will work.
If it doesn't work, you have to check your IE. Try to reinstall IE and run the scripts. Pls see the next tip.
For IE7, You may need to reinstall Silktest again.
Tip6 - Support for DLLs
Silktest is supporting only standard DLLs (like kernal32.dll, user32.dll) and it is not supporting COM Dlls like which is having class concepts (like VBA Applications). Standard DLLs are developing by using C, C++, VC++. I'm not sure about c#. But you can't create Standard Dlls by using VB.
To support COM Dlls, A Wrapper could be written for the COM DLL in some other language (C, Visual Basic, WSH, etc).
February 06, 2008
Tips4 - To Access a Excel by without pre-defined DSN
In Silktest, there is no built-in functions provided to access data from Excel. But we can access Excel data, by treating Excel as Database. By using below code snippet, you can access the Excel data without creating any DSN. You can directly pass Excel filename and worksheet name.
Code
[+] public void ProcessExcelData(STRING sExcelFile, String sExcelSheet)
[ ] // Purpose: Drives test suite based on excel sheet(testcase) information.
[ ] // Executes for given worksheet.
[ ] //SQL declaration
[ ] HANDLE hDB
[ ] HANDLE hSQL
[ ] List of STRING glsData //To get testdata
[ ]
[ ] Print ("Test data:{sExcelFile} & Worksheet: {sExcelSheet} ")
[ ]
[-] do
[ ] hDB = DB_Connect ("DRIVER=Microsoft Excel Driver (*.xls);DRIVERID=790;FIRSTROWHASNAMES=1;READONLY=FALSE;DBQ={sExcelFile}")
[ ]
[ ] //execute a SQL statement
[ ] hSQL = DB_ExecuteSQL (hDB, "SELECT * from [{sExcelSheet}$]")
[ ] //while there are still rows to retrieve
[-] while DB_FetchNext (hSQL, glsData)
[ ] GetListData (glsData) //Get all data without null
[ ]
[ ]
[ ] //clean up the query
[ ] DB_FinishSql (hSQL)
[ ]
[ ] //disconnect from the database
[ ] DB_Disconnect (hDB)
[ ]
[-] except
[ ] ExceptLog()
[ ] Print ("Excelsheet {sExcelFile} couldn't be accessed by SilkTest.")
[ ]
[ ]
Tips3 - To get all sub folders
This code snippet will be helpful to get all sub folders.
CODE:
[ ]
[+] LIST OF STRING GetDirectories (STRING sDirPath)
[ ]
[ ] LIST OF FILEINFO lfFiles
[ ] FILEINFO file
[ ] LIST OF STRING lsDirsFound = {...}
[ ]
[ ]
[-] if ! SYS_DirExists ( sDirPath )
[ ] LogWarning ( "Cannot find '{sDirPath}' on file system" )
[ ]
[ ] lfFiles = SYS_GetDirContents (sDirPath)
[ ]
[-] for each file in lfFiles
[-] if (file.bIsDir)
[ ] ListAppend (lsDirsFound, sDirPath + "\" + file.sName)
[ ]
[ ] ListSort (lsDirsFound)
[ ]
[ ] return lsDirsFound
February 05, 2008
Tips - To Access a MDB by without DSN
It is difficult to configure DSN, whenever the script runs. By using following code, you can run the script without creating DSN.
[ ] STRING CONN_STRING = "Driver=" + Chr(123) + "Microsoft Access Driver (*.mdb)" + Chr(125) + ";Dbq=\\MyServer\usertest.mdb;Mode=16;"
[ ] HDATABASE dbConn
[ ] dbConn = DB_Connect(CONN_STRING)
[ ] DB_ExecuteSql(dbConn, command)
February 04, 2008
Stopping SilkTest Execution
Ho do you do stop execution while running test cases and you have problem in accessing the Silktest host software because agent is doing all the UI actions on the GUI application and even when you bring Silktest host front, agent is setting the application active?
When you are not able to access the silktest Run->Abort simply press
right <Shift> and left <Shift> buttons at the same time. It will stop the execution.
SilkTest tutorials
I always interested to go through the tutorials. You may get to know few more info or technical things.
1. http://www.automationexpertise.com/Tutorials/SilkOrganizer/pages/Parent.htm
2. http://www.geocities.com/pammal_sureshbabu/silktest/
OR http://www.geocities.com/pammal_sureshbabu/silktest/indexnot.html
3. http://tolytech.com/documents/Public/SilkTest%20FAQ.htm#Q7
Test Automation Framework
Nowadays most of the people are talking about the framework. But most of them are not clear about the framework concepts.
Here I'm writing my view about the framework.
Automation Framework is a concept, similar to OOPs. Automation Framework is an advanced thought from Record&Playback or writing some functions and executing them.Automation Framework is a discipline and should have proper design/architecture. You can understand and implement. Automation Framework should have some of following components.
Components of a Framework
1. AUT Specific libraries
2. Tool wrapper function libraries.
3. Execution Engine (Script Execution should be drived
based on given test data) - Data Driven 4. Results
reporting mechanisms (PASS & FAIL for each
testcases/procedures and compiled results for all. It
would be better, if it captured AUT's snapshots) 5.
Planning for long term automation.
6. Keeping GUI objects info/declarations dynamically
or static.
7. Planned approach of unattended execution.
Also framework design differs by tool, scripting languages and type of AUT etc,. Now a days, people are using PERL, PYTHON, TCL/TK for CLI (Command Line Interface) automation. This design will vary much from GUI specific tool automation's design (QTP, Winrunner, Silktest,Robot and QARun etc).
You can go through following links. Each link is giving different set of components for Automation framework.
http://www.sqa-test.com/w_paper1.html
http://safsdev.sourceforge.net/FRAMESDataDrivenTestAutomationFrameworks.htm
http://www.qacity.com/NR/QACity/Documents/Automation_Framework.PDF
http://www.softwaredioxide.com/testing2004/papers/pankaj_cognizant.pdf
http://www.cbueche.de/FRM_DOC/webhelp_eng/Basic_Concepts.htm
I have developed different frameworks for Rational Visual Test, Winrunner and SilkTest. Some free frameworks are available freely on the net. EMOS is available for Winrunner and QTP. SAFS(http://safsdev.sourceforge.net) gives support for Winrunner and Robot. STAF(http://staf.sourceforge.net) will differ from SAFS.
Any pros & cons?
Clicking on HtmlText Object
Advanced web technologies are always a challenge for Automation. Few enterprise web applications have HtmlText object for navigating purpose. They look like HtmlLinks or HtmlPushButtons. Actually those are HtmlText objects.
Silktest is always trying to click first position of HtmlText object. For ex. Assume that my text object is MyApp.MainFrame.Apply
MyApp.MainFrame.Apply.Click () is equal to MyApp.MainFrame.Apply.Click (1,1,1)
Sometimes the click will not happen properly. We can't use DoClick method for HtmlText objects. At that time, we need to use two ways. One is Clicking on center of that object or blindly give some co ordinates.
In first way, MyApp.MainFrame.Apply.ClickCenter ()
- Here I've extended the click function.
In second way, MyApp.MainFrame.Apply.Click (1,6,3)
Tips1 - To Start the Application
Sys_execute will work for non-GUI command/application. will not work for Notepad and other GUI apps.
For GUI applications, use app_start("notepad") and use "bwcompat.inc"
SilkTest cannot see any children in my browser page in IE6.x
Problem
SilkTest does not recognize any children in your application running on Internet Explorrer 6.0.
Solution
If you are using IE6.x and only see a BrowserChild with no child objects within it, then make sure that the following option is enabled on the Internet Options dialog in IE6.x:
1 Click Tools/ Internet Options.
2 On the Internet Options dialog, click the Advanced tab and scroll to the Browsing section.
3 Check Enable third-party browser extensions (requires restart).
4 Restart your computer.
Note that by default, the option is enabled in IE6 and IE6 SP1. However, the option is disabled by default in IE6.0.3, which ships with Win2003 Server. Therefore customers using IE6.0.3 are likely to run into this problem.
HtmlText object can not be Parent object
If Silktest identifies, HtmlText objects as parent objects, It is very difficult to manage scripts. To avoid such instance, you need to set ShowOverflow = FALSE in domex.ini. You can set this option by coding also.
BrowserPage.SetUserOption("ShowOverflow", FALSE,USEROPT_DEFAULT)
See the Help -- Why is a new layer of HtmlText being recorded by SilkTest 6.0?