Saturday, May 3, 2008

QTP - TextBox Length

I was going through EMOS Framework. I think that this framework has been developed in QuickTest Professional 6.5 There I have seen a function to find the text box length. Below I have given that code snippet, which is very simple.

Code:

Public Sub BrowserWebEdit (strWebEdit,strInValue) If strInValue <> "" Then 'Get Length of strInValue InLenCount = Len(strInValue) 'Get Max Length for input LenCount = Browser(strBrowser).Page(strPage).WebEdit(strWebEdit).GetROProperty ("max length") If InLenCount > LenCount Then If LenCount <> -1 Then 'Trim Length of input Reporter.ReportEvent micWarning, strInValue , InLenCount & ": Length exceeds field input value trimed to: " & LenCount strInValue = Left(strInValue, LenCount) End If End If Browser(strBrowser).page(strPage).Sync Browser(strBrowser).Page(strPage).WebEdit(strWebEdit).Set strInValue End If End Sub

Friday, May 2, 2008

VBScript - File Read and Write

I have developed few projects using Visual Basic. But I do not have much scripting in Visual Basic Script (VBS). In VB, the file handling functions are different than VBScript. We need to use FileSystemObject for file handling. Below I have given two code snippets to read and write into text files. This code can be used into Quick Test Professional also.

Reading a Text file



Const ForReading = 1, ForWriting = 2

FileName = "D:\VBs\Mysamples\1create.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")

If objFSO.FileExists(FileName) Then

Set objTextFile = objFSO.OpenTextFile(FileName, ForReading)

Do while Not objTextFile.AtEndOfStream
sLine = objTextFile.ReadLine
Wscript.Echo sLine
loop

End If

objTextFile.Close

Set objFile = Nothing
Set objFSO = Nothing


Writing to a Text file


Const ForAppending = 8
FileName = "D:\VB\Mysamples\1create.txt"

Set objFSO = CreateObject("scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile (FileName, ForAppending, True)

For iIndex=1 to 10
objTextFile.WriteLine(iIndex)
Next

objTextFile.Close

Set objTextFile = Nothing
Set objFSO = Nothing

Wednesday, April 30, 2008

Accessing Excel - SilkTest

Few tools are providing built-in functions to read and write the data from Excel. Testers are comfortable with Excel than text file formats.

Silktest does not have any built-in functions to access data from Excel. But you can retrieve the data from Excel by treating Excel as Database. By using below code snippet, you can access the Excel data without pre-defined DSN. For this code snipper, You need to provide Excel filename with full path and worksheet name.

Silktest Excel - 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.")

Tuesday, April 29, 2008

Download Virtual TechDays Presentations

Few days back, I have written about Microsoft's Virtual TechDays. Now Microsoft has shared all presentations and webinars (videos). You can get all 32 sessions materials. All sessions are on Microsoft's three new products - Windows Server 2008, SQL Server 2008 and Visual Studio 2008. It is good to see the sessions from experts. You can download from following URL.

Download Page: http://www.microsoft.com/india/virtualtechdays/

Monday, April 28, 2008

Data Driven Approach

Data driven scripts are those application-specific scripts manually coded in the automation tool’s proprietary language and then modified to accommodate variable data. Variables will be used for application under test input and execution of program selections. This allows the script to drive the application with external data supplied by the test engine. Most of the automation tools are having the feature to convert a recorded script into data driven script. The tools such as Silktest, WinRunner and QuickTest Professional are using Excel file as data file format.

Though these methodologies recommended by conspicuous experts are powerful but the utilization of the advantages propounded by these methods in the Test Automation architecture is under question.

Limitations of Data Driven Approach:


  • Multiple data files are essential for this approach and hence the maintenance of these files becomes a nightmare. Each and every Test Case requires inputs and verifications from different files.

  • Testers should carefully enter the data if anything at all changes in all the required files.

  • Script processing errors are common if a proper attention is not given to the file formats.

  • The process of coding and maintaining the tests was tedious and time-consuming. It took a lot of time to create all these tests because there was no modularity and therefore no code reuse.


Due to the ineffective usage of these methods, data driven scripts still contain the hard coded and sometimes very fragile recognition strings for the window components they navigate. When this is the case, the scripts are easily broken when an application change or revision occurs. And when these scripts start breaking (not necessarily just a few). We are sometimes talking about a great many, if not all the scripts, for the entire application.

Saturday, April 26, 2008

Fantasy about Record and Playback

Many testers do not have strong programming skills. With the scripting problems, it leads testers to use record and playback techniques. There indeed are many tools that allow scripts to be recorded and then played back, using screen captures for verification.

Every automated test tool vendor will tell you that their tool is "easy to use" and that your non-technical user-type testers can easily automate all of their tests by simply recording their actions, and then playing back the recorded scripts. This one statement alone is probably the most responsible for the majority of automated test tool software that is gathering dust on shelves in companies around the world. We have seen the vendor’s sample applications. We have seen the tools play nice with those applications. And we try to get the tools to play nice with our applications just as fluently. Inherently, project after project, we do not achieve the same level of success.

The Record / Playback Myth:
The problem that an always crop up is that the layouts are changed, invalidating the screen captures and then the interface controls change making playback fail. Now the scripts must be re-recorded from scratch. Record and playback tools provide an easy way to create throwaway test suites.

You can easily notice that identification of controls and windows is through the co- ordinates of the screen. The scripts will be broken easily when there is a change in resolution of the screen.

The scripts resulting from this method contain hard-coded values, which must change if anything at all changes in the application.

If the tester makes an error entering data, etc., the test must be re-recorded. If the application changes, the test must be re-recorded.

Sometimes this manifesto is hard to explain to people who have not yet performed significant test automation with these capture \ replay tools. But it usually takes less than a week, often less than a day, to hear the most repeated phrase: "It worked when I recorded it, but now it fails when I play it back". But this is true in case of record and play back tool.

Friday, April 25, 2008

Loading a URL - Silktest

Silktest has two methods LoadPage and Navigate to load particular page or URL. Sometimes our project may have modal popups like network authentication or Certificate Security (SSL) popups before loading the page. At that time we can not use LoadPage and Navigate methods. Silktest is used to expect the browser, should be ready. In case of modal dialog box, browser will be active if the modal dialog box is closed.

To solve this problem, we need to type the URL and then hit ENTER key in the browser. Then verify for the possible popups and do appropriate actions. Few people might be using SetTrap and ClearTrap. Trapping can be done for the popups, which are not required any inputs. Below I have given a code snippet.

Code:



[ ] Browser.SetActive ()
[ ] Browser.Maximize()
[ ] Browser.Location.SetText ("{sUrl}")
[ ] Browser.Location.TypeKeys ("")
[ ] Sleep (2)
[+] if (BrowserSecurityInfo.Exists(5))
[ ] BrowserSecurityInfo.SetActive ()
[ ] Print ("BrowserSecurity Info Exists.")
[ ] BrowserSecurityInfo.Continue.Click ()
[+] if (BrowserAuthentication.Exists(5))
[ ] BrowserAuthentication.SetActive ()
[ ] BrowserAuthentication.UserName.SetText (sUsername)
[ ] BrowserAuthentication.Password.SetText (sPassword)
[ ] BrowserAuthentication.OK.Click ()

Thursday, April 24, 2008

Strange behaviour with Service Pack

Recently I installed Windows XP Service Pack3 Rel1 (en_windows_xp_service_pack_3_release_candidate_1_x86_60967.exe) in my PC. I restarted the system. But it is not able to boot at all. All my efforts went to vein. I asked few of my friends. Then I came to know, F8 key is used to select different mode of booting.

Different startup modes:


  1. Safe Mode

  2. Safe Mode with Networking

  3. Safe Mode with Command Prompt

  4. Enable Boot Logging

  5. Enable VGA Mode

  6. Last Known Good configuration

  7. Directory Services Restore

  8. Debugging Mode

  9. Disable Automatic restart on system failure

  10. Start windows normally

  11. Reboot

  12. Return to OS choices Menu


From Directory Services Restore option, I got following information.
"STOP: c0000139 {Entry Point Not Found}
The procedure entry point GdiGetBitmapBitSize could not be located in the dynamic link library GDI32.dll"


Then I searched in the net and I came to know, this problem affects many users. Solution - Original Post . This issue happens with 3311 build of XP SP3. You need to do following steps.
1. Boot from a Windows CD and go for the repair option.
2. Copy gdi32.dll from c:\windows\servicepackfiles\i386\gdi32.dll to c:\windows\system32\gdi32.dll. (Do keep a backup copy of the old gdi32.dll in c:\windows\system32 directory)
3. Reboot normally

I am not an expert in OS installation. It is very hard to follow these steps. I have done after few restarts and now able to work on my system.

Steps involved:

  1. Put your windows XP CD

  2. Restart the system

  3. Press Ctrl+Alt+Del for 5-10 seconds.

  4. CMOS setup will be opened.

  5. Go to Booting priority and set first priority to boot from CD/DVD drive.

  6. Screen will ask to type any key. It means, it is booting from your CD.

  7. Select Windows Repair option

  8. System will load few files from CD and it will ask "Do you want to continue" in command prompt.

  9. Type 1 in the command prompt. If ENTER is pressed, booting will be cancelled.

  10. Type cd System32

  11. Type ren gdi32.dll gdi32.dll.orig

  12. Type cd dllcache

  13. Type ren gdi32.dll gdi32.dll.orig

  14. Type cd \windows\servicepackfiles\i386

  15. Type copy gdi32.dll C:\Windows\System32\

  16. Type Exit



Then System restarts normally. I uninstalled SP3 as first job. Now my system is working fine. Due to this issue, I am unable to use this system for 4 days.

I used to check versions of softwares in our application. We need to specify clearly the version and Service Pack /Fix pack of all required softwares in Software Requirements.

Wednesday, April 23, 2008

Tooltip verification in Browser

SilkTest does not have any built-in function, to get tooltip from browser controls. In browser, there is no ToolTip control, but the few attributes (Alt) are used to simulate a ToolTip.

Using Silktest, we can execute javascript statements in browser at runtime. By using that, we can get tooltip from web objects. In the following example sAltProp variable gets the tooltip of AutoImage object.

STRING sAltProp = MyApp.AutoImage.ExecMethod('getAttribute("alt")')

Similarly we can use javascript to get more info from any browser based objects. QTP is using VBScript. Using QTP also, we can achieve the same like above.

Friday, April 18, 2008

Difference between Application server and Web server

I have explained the difference between Application server and web server. I prepared this table after referring few sites. I hope that it will be very useful to you.

Application server

Web server

Developers can create, test, and execute application components.

It is designed to create and deploy Web site, serving up content more so than applications.

These are typically J2EE-based, running EJBs or other Java components.

It supports JSP,Servlets,ASP and server side Java Script.

It exposes business logic to client applications through various protocols.

It is designed to create and deploy Web site serving.It mainly deals with sending HTML for display in a web browser.

Application Server supports HTTP,TCP/IP and many more protocols.

A Web Server understands and supports only HTTP protocol.