After creating my blog, I searched my blog on Google. My blog is not displayed in search results. Then I started to read more about Publicizing the blog. Also I read about Search Engine Optimization (SEO). SEO helps to create high visibility on the leading search engines. It also helps to bring more visitors to your page and indirectly marketing your website.
Brad Callen is one of the search engine optimization experts. He has written a book about SEO. Brad has mentioned two types of optimization. One is OnPage optimization and another one is OffPage optimization. You can download his E-book from docstoc.com.
To know more about SEO, see this Wiki page . Also now You can do Search on my blog.
Monday, April 14, 2008
SEO - Search Engine Optimization
Saturday, April 12, 2008
HtmlText object not a Parent
Three years ago, we have upgraded Silktest version to 6.5. At that time, Silktest identified HtmlText objects as parent objects. We changed our scripts lot and it was difficult to manage the scripts release by release. Then I found that we need to set a Agent option in Silktest. You can avoid this by two ways.
- By coding. You need to use this statement after invoking the browser object => BrowserPage.SetUserOption("ShowOverflow", FALSE,USEROPT_DEFAULT)
- By configuration. Add ShowOverflow=FALSE under [Options] in extend\domex.ini
Friday, April 11, 2008
Microsoft - Virtual TechDays
April 9th and 10th 2008, Microsoft’s Virtual TechDays was held at Bangalore. More than ten thousand engineers would have benefited. To attend this program, user should install Microsoft's Live Meeting in their machine. Totally 32 sessions were there. 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. I attended SQL Server 2008 and VS 2008 sessions. I missed the BI sessions due to my vacation.
Microsoft has given plenty of information for all sessions. User can get various resources (evaluations, whitepapers, videos) from that site. Below I have given few links and hope that it might be useful to you.
Virtual TechDays - Resources
SQL Server 2008 - Overview
Visual Studio Team System Videos
Thursday, April 10, 2008
Checking Mail Notification
Earlier I have written the code to verify the mails from Microsoft Outlook Express. I used to call CDO(Collaboration Data Objects) object methods. I developed a small VB application to delete all the objects from Inbox. I think, now few methods are deprecated.
Code:
'It is possible, by calling OLE objects from CDO.dll
'Mostly it will be in C:\Program Files\Common Files\System\Mapi\1033\NT\
'-------------------------
' Method : CheckMail
' Author : T.Palani Selvam
' Purpose : Check the mails in the MS Outlook Mail Client for the particular subject & its status.
' Parameters: sDatavalue, String - Contains Username, Password of the MS outlook, Subject & Status of mail.
' Returns : Returns Integer data type(True or False.)
'----------------------------
Function CheckMail(sDataValue As String) As Integer
Dim objSession As Variant
Dim objInbox As Variant
Dim objMessages As Variant
Dim objItem As Variant
Dim intIndex As Integer
Dim intCount As Integer
Dim varReceived As Variant
Dim iStatus As Integer 'To get Current status of the message.
Dim sSubject As String 'Subject of the current message.
Dim sUser As String, sPword As String, sSearch As String, sStatus As String 'Information gets from the Data value
Dim iPosition As Integer, iPosition1 As Integer
Dim sTemp As String
Dim iResult As Integer
iResult = False 'Initializing function
'Error Information Handling
On Local Error GoTo Error_Handler1
'****** Parsing information from Datavalue
sTemp = sDatavalue
intCount = 1
While (Instr(sTemp,"::") <>0 )
iPosition = Instr(sTemp,"::")
Select Case intCount
Case 1
sUser = Left$ (sTemp, iPosition - 1)
Case 2
sPWord = Left$(sTemp, iPosition - 1)
Case 3
sSearch = Left$(sTemp, iPosition - 1)
'Case 4
'sStatus = Left$(sTemp, iPosition)
sStatus = Mid$ (sTemp, iPosition + 2)
Case Else
LogWrite("CheckMail: More information is given in data file.", 1)
End Select
intCount = intCount + 1
sTemp = Mid$ (sTemp, iPosition + 2)
Wend
'**** End Parsing Information
Logwrite("Search Mail Status: " + sStatus + " & Subject String: " + sSearch, 1)
'Set objSession = CreateObject("MAPI.Session")
objSession = OleCreateObject("MAPI.Session") ' Create MAPI session
'objSession.Logon strUser, strPword, False, False, 0
OleDispatch(objSession,"Logon",sUser, sPword,False, False, 0) ' Logon using an existing MAPI session
'Set objInbox = objSession.Inbox
objInbox=OleDispatch(objSession,"Inbox") ' Get inbox folder
'Set objMessages = objInbox.Messages
objMessages=OleDispatch(objInbox,"Messages") 'Get all messages
intCount=OleGetProperty(objMessages,"Count")
LogWrite("Total Messages in Outlook: " + str(intCount) , 1)
sStatus = Trim (sStatus)
For intIndex=1 To intCount Step 1
objItem=OleDispatch(objMessages,"Item",intIndex) 'Get Each message
sSubject = OleGetProperty(objItem,"Subject")
iStatus = OleGetProperty(objItem,"Unread")
If (InStr(UCase(sSubject), UCase(sSearch)) <> 0) Then
If (iStatus AND (Instr(lCase(sStatus),"read") > 1)) Then
iResult = True
Exit For
ElseIf ((Not iStatus) AND (Instr(lCase(sStatus),"read") = 1)) Then
iResult = True
Exit For
End If
End If
Next intIndex
' Logoff from MAPI Session
OleDispatch(objSession,"Logoff")
'Set objSession = Nothing
OleReleaseObject(objSession)
If (iResult) Then
LogWrite("Successfully Mail is checked in the Outlook.",2)
Else
LogWrite("Failure to check Mail in the Outlook.",1)
'giTestResult = giTestResult + 10
End IF
CheckMail = iResult
Exit Sub
Error_Handler1:
If InStr(UCase(Error$), "LOGON") <> 0 And InStr(UCase(Error$), "FAIL") <> 0 Then
LogWrite("CheckMail : Username and password of Outlook information are incorrect. ", 1)
LogWrite("CheckMail : MS Outlook Login status is Failure.", 1)
End If
If Not (objSession = NULL) Then
OleReleaseObject(objSession)
End If
'PRINT "[Failed At] " ERF "(" ERL ") : " ERROR$ 'Actual location.
'PRINT "[Trapped At] " ERF(1) "(" ERL(1) ")" 'Trapped location.
LogWrite("[Failed At] " + ERF(0)+ "("+ str(ERL) +") : "+ ERROR$,1) 'Actual location.
Logwrite("[Trapped At] "+ ERF(1)+ "("+ str(ERL(1))+ ")",1) 'Trapped location.
LogWrite("Error Handling: Failure to check Mail in the Outlook.",1)
glCellRow = glCellRow + 1
setResultDetails("Error: " + Error$ ,glCellRow,3) 'Write into Excel
End Function
Sunday, April 6, 2008
Screen Saver Off
All GUI test suite are not executed if screen saver screen is displayed or machine gets locked. Before running the scripts, automation engineer should confirm not to get the machine lock or screen saver. In few environments, user would not able to control.
Earlier I also faced this problem. Then I used to login as a local user instead of network user or company login id. Later we used VmWare Workstations to run the regression.
You can avoid this situation by few ways.
- Using Registry
- Using scripting while regression starts
- Restart the Machine if system gets locked
Using Registry
It is a simple method. But it should not overriden by your company policy. System Admin may run your company screen savers.
1. Go to HKEY_CURRENT_USER
Path => [HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Control Panel\Desktop]
2. Change the following values for following keys.
"ScreenSaveActive"="1"
"ScreenSaveTimeOut"="30000"
Using scripting while regression starts
1. Disable the screen saver. Below code is given for Silktest. Put into ScriptEnter block.
// Declaration
dll "user32.dll"
LONG SystemParametersInfo (LONG uAction, LONG uParam, LONG lpvParam, LONG fuWinIni) alias "SystemParametersInfoA"
// Calling statement
-> SystemParametersInfo (17, 0, 0, 0)
2. Enable the screen saver. Keep below code into ScriptExit function.
// Calling statement
-> SystemParametersInfo (17, 1, 0, 0)
Restart the Machine if system gets locked
User can call any batch script or system restart command. But you need to re-execute the scripts, from where it was stopped. It is a bit complex trick.
Saturday, April 5, 2008
VisualTest - File Handling
Any automation suite must have file handling functions for various scenarios. It may be just text files or any data files. VisualTest also has few methods for file handling. VisualTest code is similar to Visual Basic code. Below I put some of my visual test functions.
Code: Check the given file exists or not
'----------------------------------
' Method : FileExists
' Author : T.Palani Selvam
' Purpose : Check the given file exists or not. PhaseII
' Parameters: sFile, String - Contains a file name.
' Returns : Returns Integer data type(True or False.)
' Caller : SwitchSpecialTags
' Calls : - Nil
'-----------------------------
Function FileExists(sFile As String)As Integer
Dim iPosition As Integer
Dim sDir As String, sTFile As String, sTemp As String
FileExists = False
sTFile = sFile
iPosition = Instr(sFile,"::")
If (iPosition <> 0) Then
sDir = Mid$(sFile,iPosition + 2)
sTemp = Left(sFile, iPosition - 1)
If (Instr(sTemp,":\") <> 0 ) Then
sTFile = sTemp
Else
If (Right$(Trim(sDir),1) <> "\") Then
sDir = Trim(sDir) + "\"
End If
sTFile = sDir + sTemp
End IF
End If
If Exists(sTFile,"-d") Then
FileExists = True
Logwrite( "Successful - Existing file is " + sTFile , 1)
Else
Logwrite( sTFile + " - File doesn't exist.", 1)
End IF
End Function
Code: Check whether the given folder exists or not
'----------------------------
' Method : FolderExists
' Author : T.Palani Selvam
' Purpose : Check the given folder exists or not.(PhaseII)
' Parameters: sFolder, String - Contains a folder name.
' Returns : Returns Integer data type(True or False.)
' Caller : SwitchSpecialTags
' Calls : - Nil
'---------------------------
Function FolderExists(sFolder As String)As Integer
FolderExists = False
If (Right$(Trim(sFolder),1) = "\") Then
sFolder = Trim(sFolder)
sFolder = Left$(sFolder, Len(sFolder) -1 )
End If
If Exists(sFolder,"+d") Then
FolderExists = True
Logwrite( "Successful - Existing Directory is " + sFolder , 1)
Else
Logwrite( sFolder + " - Directory doesn't exist.", 1)
End IF
End Function
Code: Check whether the given string exists in the given file or not.
'-----------------------------
' Method : StringExists
' Author : T.Palani Selvam
' Purpose : 'Check whether the given string exists in the given file or not.
' Parameters: sFile as String, Contains a file name with full path.
' sWord - String , Consists of string to check into the file.
' Returns : Returns Integer value
' Caller : OperationIdentifier()
' Calls : - Nil
'-------------------------
Function StringExists(sFile As String,sWord As String)As Integer
Dim fNumber As Long
Dim sLine As String
Dim iInt As Integer
fNumber=FREEFILE
StringExists=False
iInt =0
OPEN sFile For Input As #fNumber
While not eof(fNumber)
Line Input #fNumber,sLine
sLine = Trim (sLine)
IF (Instr(sWord,sLine)<>0 AND Len(sLine) > 1) Then
PRINT sLine, "String Exists!"
iInt = iInt + 1
If (iInt > 3) Then
StringExists=True
Exit Function
End IF
End If
Wend
CLOSE #fNumber
End Function
Friday, April 4, 2008
Handling HTMLText objects in SilkTest
Silktest is always clicking top-left most point of HtmlText object. For example, Assume that my text object is MyApp.MainFrame.Apply
MyApp.MainFrame.Apply.Click () is equal to MyApp.MainFrame.Apply.Click (1,1,1)
Advanced web technologies are always becoming challenges for Automation. Our enterprise web applications have HtmlText object for navigating purpose. We changed all images to text to support localization. These text objects look like HtmlImages or HtmlPushButtons. Actually those are HtmlText objects.
My problem was, sometimes the click will not happen properly. We cannot use DoClick method for HtmlText objects. I had two tricks to solve this problem. One is Clicking on center of that object or blindly hardcode co-ordinates.
In first way, MyApp.MainFrame.Apply.ClickCenter ()
- Here I have extended the click function.
In the second way, MyApp.MainFrame.Apply.Click (1,6,3)
Thursday, April 3, 2008
Unable to run VBS in Windows XP
Last Year my machine was formatted and windows XP (SP2) was installed. Recently I tried to run few Visual basic scripts (VBS). An error message thrown and unable to run any VB script.
Then I searched and came to know that I need to install Windows Script 5.6 for Windows XP. After installing it, I am able to run the scripts in my PC. Also few links from search results are invalid. Now Windows Script 5.7 is available. Below I have given the links to download script engines. Hope that It will be useful...
Wednesday, April 2, 2008
VisualTest - Using Excel Application
Our Automation suite results were in text files. I wanted to create the excel file as results file. You can get to know more about Results Reporting. I used Excel VBA for this. It has simplified my task to prepare the compiled results for entire execution.
Similarly I will write, how to do the same thing by using VB script later....
Code: To check Excel availability in the system
'--------------------------------------
' Method : IsExcelAvailable
' Author : T.Palani Selvam
' Purpose : Checks whether excel application is available or not.
' Parameters: - Nil
' Returns : Returns integer, whether true or false.
' Caller :
' Calls :
'--------------------------------
Function IsExcelAvailable() As Integer
Dim objExcelApp As Variant
ON LOCAL ERROR GOTO Errhandler
IsExcelAvailable = False
objExcelApp = OleCreateObject("Excel.Application")
Sleep 0.5
OleReleaseObject(objExcelApp)
IsExcelAvailable = True
Exit Function
ErrHandler:
'LogWrite("[Failed At] " + ERF(0)+ "("+ str(ERL) +") : "+ ERROR$ + " .Error Number: " + str(Err),1) 'Actual location.
'Logwrite("[Trapped At] "+ ERF(1)+ "("+ str(ERL(1))+ ")",1) 'Trapped location.
Logwrite("Excel Application is not available.", 2)
End Function
Code: To Read Excel data
'---------------------------------------
' Method : ReadExcelCells
' Author : T.Palani Selvam
' Purpose : Read the content from given Excel file
' and checks result automatically, while completing a test case.
' Parameters: - Nil -
' Returns : - Nil -
' Caller :
' Calls :
'
'--------------------------------------
Function ReadExcelCells(sExcelFile as String, sWorkBook as String,sWorkSheet as String,sArrFields() As String) As Integer
DIM objExcelApp As Variant,objExcel As Variant, objCurrentCell As Variant
DIM objWorkBook As Variant,objWorkSheet As Variant
Dim iRows As Integer, iCols As Integer
Dim iRowStatus As Integer, iColStatus As Integer
Dim iRowIndex As integer, iColIndex As integer, iIndex As Integer
Dim sCellValue As String, sValue as String
ReadExcelCells = False
objExcel = OleGetObject (sExcelFile)
objExcelApp = OleDispatch (objExcel,"Application")
'objExcelApp = OleCreateObject ("Excel.Application")
objWorkBook = OleDispatch (objExcelApp,"Workbooks", sWorkBook)
'objWorkBook = OleDispatch (objExcelApp,"Workbooks")
'OleDispatch(objWorkBook,"Add",sWorkBook)
objWorkSheet= OleDispatch (objWorkBook,"Sheets", sWorkSheet)
iIndex = 1
Do While Not (iRowStatus)
objCurrentCell= OleDispatch (objWorkSheet, "Cells", iIndex, 1)
sValue = OleGetProperty (objCurrentCell, "Value")
If (Len(Trim(sValue)) = 0 ) Then
iRowStatus = True
End IF
iIndex = iIndex + 1
Loop
iRows = iIndex - 2 'Rows Count
print "No of rows.." + str(iRows)
iIndex = 1
Do While Not (iColStatus)
objCurrentCell= OleDispatch (objWorkSheet, "Cells", 1, iIndex)
sValue = OleGetProperty (objCurrentCell, "Value")
If (Len(Trim(sValue)) = 0 ) Then
iColStatus = True
End IF
iIndex = iIndex + 1
Loop
iCols = iIndex - 2 'Rows Count
print "No of Columns.." + str(iCols)
ReDim sArrFields(iCols - 1,1) As String
For iIndex=1 To iCols
objCurrentCell= OleDispatch (objWorkSheet, "Cells", 1, iIndex)
sValue = OleGetProperty (objCurrentCell, "Value")
sArrFields(iIndex-1, 0) = sValue
Next iIndex
For iRowIndex = 2 To iRows
For iColIndex = 1 To iCols
objCurrentCell= OleDispatch (objWorkSheet, "Cells", iRowIndex, iColIndex)
sValue = OleGetProperty (objCurrentCell, "Value")
sArrFields(iColIndex-1, 1) = sValue
Next iColIndex
For iIndex = LBOUND(sArrFields,1) TO UBOUND(sArrFields,1)
Print "Field (Name,Value): " + sArrFields(iIndex, 0),sArrFields(iIndex, 1)
'Print "Field Value: " + sArrFields(iIndex, 1)
Next iIndex
Next iRowIndex
OleReleaseObject (objWorkSheet)
OleReleaseObject (objWorkBook)
OleReleaseObject (objExcelApp)
OleReleaseObject (objExcel)
ReadExcelCells = True
End Function
Code: To set Test Results by different colors
'-------------------------------------------------------------------------
' Method : setResultXLDetails
' Author : T.Palani Selvam
' Purpose : Set the standard format for the given Cell Object.
' Parameters: sDetails - String, contains information to be written into Excel cell object
' lRow - Long, contains row number
' lCol - long, contains Column number
' iFontType As Integer
' iFontColor As Integer
' Returns : -Nil
' Caller :
' Calls :
'-------------------------------------------------------------------------
'Default values will be given iFontType =0, iFontColor =0
Sub setResultXLDetails(sDetails As String, lRow As Long, lCol As Long,iFontType As Integer, iFontColor As Integer)
Dim objCell As Variant, objFont As Variant
If Not IsNull(gObjWorkBook) Then
objCell = OleDispatch(gObjWorkSheet,"Cells",lRow,lCol)
objFont = OleDispatch(objCell, "Font")
Select Case iFontType
Case 1
OleSetProperty(objFont,"Bold",True)
Case 2
OleSetProperty(objFont,"Italic",True)
Case 3
OleSetProperty(objFont,"Bold",True)
OleSetProperty(objFont,"Italic",True)
Case Else
End Select
Select Case iFontColor
Case Is < 1
Case Is < 26
OleSetProperty(objFont,"ColorIndex",iFontColor)
Case Else
End Select
OleSetProperty(objCell,"Value", sDetails)
OleReleaseObject(objFont)
OleReleaseObject(objCell)
End IF
End Sub
Code: To set value into given cell
'-------------------------------------------------------------------------
' Method : setResultDetails
' Author : T.Palani Selvam
' Purpose : Set the standard format for the given Cell Object.
' Parameters: sDetails - String, contains information to be written into Excel cell object
' lRow - Long, contains row number
' lCol - long, contains Column number
' Returns : -Nil
' Caller :
' Calls :
'-------------------------------------------------------------------------
Sub setResultDetails(sDetails As String, lRow As Long, lCol As Long)
Dim objCell As Variant
If Not IsNull(gObjWorkBook) Then
objCell = OleDispatch(gObjWorkSheet,"Cells",lRow,lCol)
OleSetProperty(objCell,"Value", sDetails)
OleReleaseObject(objCell)
End IF
End Sub
Tuesday, April 1, 2008
SilkTest - Convert .jou to results file
Journal (*.jou) file is created, While SilkTest scripts are running. Results are stored temporarily in this. Journal file is converted to a .res file, when the script finishes running.
You re-run that particular script/plan/suite file for a testcase and then stopped manually within 5-10 minutes. In the results file, You can see the results for previous run Or select the previous results. There you can see the results of previous execution.
Remove the jou file, if SilkTest reports the error "Could not open results file."
