Saturday, September 3, 2011

SAP Edit box(SAPGuiEdit) Validation Code

'***********************************************************
*******************************************************
'SAPGuiEdit Customize Field Validation Code -
'Name : fieldValidation()
'Purpose : To validate a text field
'Author : MindLess
'Input : Edit Box name, label text, error level
' : expectedVal special cases:
' : "<no_validation>" if validation is not required for the componenet
' : "<blank>" if it is required to check blank value i.e. expected value is blank.
'     : "<any_value>" to check any value except blank
'Output : Temp results stored in buffer excel file
'Return : NA
'Assumptions : None
'Note : None
'******************************************************************************************************************
sub fieldValidation(boxname,expectedVal,errorLevel)
If expectedVal = "<no_validation>" Then
Exit Sub
End If
'on error resume next
Dim sessionDesc,winDesc,childDesc,winDescModal,obj,window,blnEdtPresent,val,field,i
Set sessionDesc = description.Create()
sessionDesc("type").value = "GuiSession"
Set winDesc = description.Create()
winDesc("type").value = "GuiMainWindow"
Set winDescModal = description.Create()
winDescModal("type").value = "GuiModalWindow"
Set edt = description.Create()
edt("type").value = "Gui.*TextField"
edt("name").value = boxname
blnEdtPresent = false
If SAPGuiSession(sessionDesc).SAPGuiWindow(winDesc).Exist(2) Then
Set window =SAPGuiSession(sessionDesc).SAPGuiWindow(winDesc)
else
Set window = SAPGuiSession(sessionDesc).SAPGuiWindow(winDescModal)
End If
set obj = window.SAPGuiEdit(edt)

If obj.exist(2) Then
val= obj.getroproperty("text")
field = obj.getroproperty("DefaultTooltip")
If val<>"" Then
If expectedVal="" Or expectedVal="<any_value>" Then
blnEdtPresent=true
End If
If expectedVal<>"" and expectedVal=val Then
blnEdtPresent=true
End If
''***********to validate with blank and any value ************
Elseif expectedVal = "<blank>" Then
blnEdtPresent=true
'**************************************************************************************************************
Else
blnEdtPresent=false
End If
i=rowCount()
If blnEdtPresent = true Then
Reporter.ReportEvent 0,"Value displayed for "& field&" is - "&val,""&i+1
 
elseif blnEdtPresent= false and val<>"" then
Reporter.ReportEvent 1,""&errorLevel&" : "&"Value displayed for "&field&" is - "&val&" and expected was - "&expectedVal,""&i+1

elseif blnEdtPresent= false and val="" then
Reporter.ReportEvent 1,""&errorLevel&" : "&field&" is missing ",""&i+1
End If
End if

Set sessionDesc= nothing
Set winDesc = nothing
Set obj = nothing
Set window = nothing
Set winDescModal = nothing
end sub

Monday, August 29, 2011

Find-Replace value in Excel: VB Script

'*********************************************************
'Author : MindLess
'version 4
'Language: VB Script
'Date 01 -Apr- 2011
'Purpose: For changing the data of Excel datasheet inside a folder.
'Just double click
'Dont Change the file name.
'You can change this script as per your requirement.


'**********************************************************
'**********************************************************
 'Main Function CallSub Inputval()
'**********************************************************
v_folderpath = Trim(inputbox("Input the folder path ", "Path..."))
v_folderpath = blankCheck(v_folderpath, "Input the folder path" )
if v_folderpath ="No" Or v_folderpath = "" Then
 Exit Sub
End If


v_no= Trim(inputbox("Input no of different data you want to change", "No of data.."))
v_no= blankCheck(v_no, "Input no of different data you want to change")
if v_no ="No" Or  v_no = "" Then
 Exit Sub
End If
'Option Explicit
Dim v_oldv()
Dim v_newv()
Redim v_oldv(v_no)
Redim v_newv(v_no)
for i= 0 to v_no - 1
v_oldv(i) = Trim(inputbox("Input the Old value", "Find..."))
if v_oldv(i) ="No" Or  v_oldv(i) = "" Then
 Exit Sub
End If
'If v_oldv <> "" then
v_newv(i) = Trim(inputbox("Input The New value for " & v_oldv(i), "Replace..")) 
v_temp = v_newv(i)
v_newv(i) = blankCheck(v_temp,"Input The New value for " & v_oldv(i))
if v_newv(i) ="No" or v_newv(i) = "" Then
 Exit Sub
End If

'End if
Next
FindReplace v_oldv, v_newv, v_folderpath, v_no
Msgbox "Done"
End Sub
'*************************************************************************
Sub FindReplace(v_old, v_new, v_path, v_no)
dim objFS, oFolder
set objFS = WScript.CreateObject("Scripting.FileSystemObject")
set objFolder = objFS.GetFolder(v_Path)
Set Fillist = objFolder.Files
'msgbox objFolder.Files.Count
Set objExcel = CreateObject("Excel.Application")
 objExcel.DisplayAlerts = False
For each fil in Fillist
 If fil.name <> "Find_Replace.vbs" Then
        'msgbox fil.name
  v_compltfilename = V_Path & "\" & fil.name
 'msgbox v_compltfilename
 'Open the workbook

 Set objWorkBook = objExcel.Workbooks.Open(v_compltfilename)
 'Set up a reference to the sheet in the workbook
 Set objWorkSheet = objWorkBook.WorkSheets(1)
 Set objRange = objWorkSheet.Range("B1")
 objRange.Select
 For i= 0 to v_no-1
 objRange.Replace v_old(i), v_new(i)
 Next
 objWorkBook.Save
 objWorkBook.Close
 End If
  next
objExcel.Quit
Set objWorkBook = Nothing
objExcel.DisplayAlerts = True
Set objExcel = Nothing

End Sub
'********************************************************
 Public Function blankCheck(v_val, msg)
If v_val = "" then
  v_msgret = Msgbox("Your value is blank. Press Retry to re enter!",5, "Alert!!! Blank value..")
 If v_msgret = 4 then
  v_new = Trim(inputbox(msg, "Retry"))
  blankCheck = v_new
 Else
  blankCheck = "No"
  Exit Function
 End If
Else
 blankCheck = v_val
End if
End Function
Public Sub closeDialog(v_val)
if v_val = "" Then
Exit Sub
End If
End Sub
'********************************** Closure**************
Set objShell = Nothing
Set objFS = Nothing
Set objFolder = Nothing
Set Fillist = nothing
'objWorkBook.Save
'objWorkBook.Close 

Sunday, August 28, 2011

Automation Testing

Automation testing is testing a software with another software. Different types of tools had also been developed for the automated testing services. Automated testing software is used to save two big factors: the cost and the money but at the same time the accuracy of the test is also enhanced.

For the working of the automated testing it must be ensured that correct and valid inputs has been entered which in turn will produce better outputs.

Automation Tools

QuickTest Pro
Worksoft Certify
Robot
Functional Tester - RobotJ 
Selenium
QARun
TestPartner 
SilkTest
e-Test
Eggplant
JTest
WebFT
OpenSTA
QALoad
Performance Tester
SilkPerformer
LoadRunner
e-Load 
WebLoad