Friday, November 27, 2009

TestComplete: - Programme customization

Sub Test1
Dim cpd
Dim frmCustomizeProgram
Dim panel
Dim textBox
Dim treeView
Dim button
Dim frmCustomizeForms
Dim label
Set cpd = Aliases.CPD
Call cpd.frmCPDMain.StripMainMenu.Click("Tools|Customize Database|Customize Programme")
Set frmCustomizeProgram = cpd.frmCustomizeProgram
frmCustomizeProgram.panel1.pnlTop.btnAddProgram.ClickButton
Set panel = frmCustomizeProgram.panel2
Set textBox = panel.txtProgramName
Call textBox.Click(152, 8)
textBox.wText = "Test Programme"
Call textBox.Keys("[Tab]")
Call panel.txtProgramMetadata.Keys("test description")
frmCustomizeProgram.pnlbottom.btnNext.ClickButton
Set panel = frmCustomizeProgram.panel3
Set treeView = panel.tvForms
j=3
MsgBox("|"+treeview.Nodes.Item(j).Text)
call treeview.ExpandItem("|"+treeview.Nodes.Item(j).Text)
for c=0 to 3
i=random(0,treeview.Nodes.Item(j).Nodes.Count-1)
call treeview.DblClickItem("|" + treeview.Nodes.Item(j).Text+"|" +treeview.Nodes.Item(j).Nodes.Item(i).Text)
aqUtils.Delay(1000)
if (panel.lstVwForms.Items.item(c).text=treeview.Nodes.item(j).Nodes.Item(i).Text) Then
Log.Message("Form selection thru double click Pass")
Else
Log.Message("Form selection thru double click Fail")
end If
Next
' --------------Checking Select button Functionality------------------------------------------
i=random(0,treeview.Nodes.Item(j).Nodes.Count-1)
Call treeview.ClickItem("|" + treeview.Nodes.Item(j).Text+"|" +treeview.Nodes.Item(j).Nodes.Item(i).Text)
Call panel.btnSelect.Click()
if (panel.lstVwForms.Items.item(4).text=treeview.Nodes.item(j).Nodes.Item(i).Text) Then
Log.Message("Form selection thru double click Pass")
Else
Log.Message("Form selection thru double click Fail")
end If
'------------verify result on doublicking already selected form--------------------------------
call treeview.DblClickItem("|" + treeview.Nodes.Item(j).Text+"|" +treeview.Nodes.Item(j).Nodes.Item(i).Text)
if panel.lstVwForms.Items.Count>5 Then
Log.Message("Double Clicking Already Selected Form | Fail")
Else
Log.Message("Double Clicking existing Form| Pass" )
end If
End Sub



function Random(min,max)
Randomize()
Random =Int ((max-min+1)*rnd+min)
end Function


Sub Test2
Dim panel
Set panel = Aliases.CPD.frmCustomizeProgram.panel3
Call panel.tvForms.DblClickItem("|Family Tracing and Reunification|FTR Adult Verification Form")
Call panel.lstVwForms.ClickItem("FTR - Rapid Registration Form", 0)
End Sub

Tuesday, November 24, 2009

Reading and Writing in Text File Vb Script

// VB Script
Sub WritetoFile( txtvalue)

dim fs,f
const ForReading=1,Forwriting=2,ForAppending=8,TristateFalse=0

path="d:\myfile.txt"

set fs=createObject("Scripting.FileSystemObject")
If not fs.FileExists(path) Then
set objFile=fs.CreateTextFile(path)
objfile.close()
End If
Set f=fs.OpenTextFile(path,ForAppending, TristateFalse)
f.write txtValue & vbCrLf
f.close()

End Sub


Sub ReadFile()

Const ForReading=1
Set fs=sys.OleObject("Scripting.FilesystemObject")
Set f= fs.OpenTextFile("d:\myfile.txt",ForReading)
f.skipline
While not f.AtEndOfstream
s=f.readline()
Count=getcsvcount(s)
For i=0 to count-1
Log.Message(Getcsvitem(s,i))
Next
Wend
f.close()

end Sub

sub test

call WritetoFile("Nitin")
call WritetoFile("Nitin")
call ReadFile()

end sub

Friday, November 20, 2009

Extending Test Complete Trial License

Delete the "regkey.dat" file on your machine. The file should be located in the following folder:

"C:\ProgramData\AutomatedQA\TestComplete\7.0" (for Windows Vista, Windows Server 2008)

"C:\Documents and Settings\All Users\Application Data\AutomatedQA\TestComplete\7.0" (for any other version of Windows


9876EDDA-9DE430BF-5BA4BEE1-6B84F60B-7BC395CD-D04A8A89-9509

TestComplete: Random Function

function Random(min,max)

Randomize()
Random =Int ((max-min+1)*rnd+min)

end Function

Accessing Grid Cell value

Property used to access grid cell value :

grid.wValue(rowindex,colindex)

Wednesday, November 18, 2009

VB Script and excel playing aroubd...

// Following code will read and write in an excel file.


Set objXL = CreateObject("Excel.Application")
Set objWB = objXL.WorkBooks.Open("C:\Documents and Settings\nsharma\Desktop\VB scripts\test1.xls")
Set objWS = objXL.ActiveWorkBook.WorkSheets("Sheet1")
Dim CellArray()
ACount = 0
For i = 1 To 10
If objXL.Cells(i, 8).Value = "" Then
CellValue = "Empty"
objXL.Cells(i, 9).Value="Pass"
Else
CellValue = objXL.Cells(i, 8).Value
End If
ReDim preserve CellArray(ACount)
CellArray(ACount) = CellValue
msgbox(cellvalue)
ACount = ACount + 1
Next
objWB.Close
objXL.Quit

QTP’S test Object Functions:


Exist: You can enter Exist and/or Wait statements to instruct QuickTest to wait for a window to open or an object to appear. Exist statements return a boolean value indicating whether or not an object currently exists. Wait statements instruct QuickTest to wait a specified amount of time before proceeding to the next step. You can combine these statements within a loop to instruct QuickTest to wait until the object exists before continuing with the test.

Example:

blnDone=Window("Flight Reservation").Dialog("Flights Table").Exist

counter=1

While Not blnDone

Wait (2)

blnDone=Window("FlightReservation").Dialog("FlightsTable").Exist counter=counter+1

If counter=10 then

blnDone=True

End if

Wend

Check Property: Checks whether the specified object property achieves the specified value within the specified timeout.

Syntax: object.CheckProperty (PropertyName, PropertyValue, [TimeOut])

Example:

var_CheckProperty = Browser("HP QuickTest Professional").Page("HP QuickTest Professional").Link("1.2 License Models").CheckProperty("text", "Licence Models")

Return Value

A Boolean value. Returns TRUE if the property achieves the value, and FALSE if the timeout is reached before the property achieves the value.

A TRUE return value reports a Passed step to the test results; a FALSE return value reports a Failed step to the test results.

GetTOProperty: Returns the value of the specified property from the test object description.

Syntax: object.GetTOProperty (Property)

Example : var_GetTOProperty = Browser("HP QuickTest Professional").Page("HP QuickTest Professional").Link("1.2 License Models").GetTOProperty("Innertext")

Return Value: A variant value which will have the inner text of the link “1.2 License Models”

GetROProperty: Returns the current value of the test object property from the object in the application.

Syntax: object.GetROProperty (Property)

Example : var_GetTOProperty = Browser("HP QuickTest Professional").Page("HP QuickTest Professional").Link("1.2 License Models").GetROProperty("Innertext")

Return Value: A variant value which will have the current inner text value of the link “1.2 License Models”

ReportEvent : Reports an event to the test results

Syntax: Reporter.ReportEvent EventStatus, ReportStepName, Details [, Reporter]

Example:

Reporter.ReportEvent 1, "Custom Step", "The user-defined step failed."

or

Reporter.ReportEvent micFail, "Custom Step", "The user-defined step failed."

SystemUtil.Run : You can run any application from a specified location using a SystemUtil.Run statement

Example:SystemUtil.Run"C:\ProgramFiles\InternetExplorer\IEXPLORE.EXE","","C:\Documents and Settings\Administrator","open"

The statement opens the Internet Explorer.

ExecuteFile: This can be used to execute an external VB Script File

Syntax: ExecuteFile FileName

Example : ExecuteFile “C:\sample.vbs”

The above discussed functions can be easily Accessed by step Generator:

VB Script File handling

File handling:

Writing Values From a File:

Const ForReading = 1, ForWriting = 2

Dim fso, MyFile

Set fso = CreateObject("Scripting.FileSystemObject")

Set MyFile = fso.OpenTextFile("c:\testfile.txt", ForWriting, True)

MyFile.WriteLine "Hello world!"

MyFile.WriteLine "The quick brown fox"

MyFile.Close

Reading Values from a File:

Const ForReading = 1, ForWriting = 2

Dim fso, MyFile

Set fso = CreateObject("Scripting.FileSystemObject")

Set MyFile = fso.OpenTextFile("c:\testfile.txt", ForReading)

Val= MyFile.ReadLine

Val1=MyFile.ReadLine

MyFile.Close

Fetching Values from a Database using VBScript.

Set MyConn = CreateObject("ADODB.Connection")

MyConn.Open"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\Program”+_ "Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight32.mdb"

Set RS = MyConn.Execute("SELECT * FROM Orders")

While Not RS.EOF

msgbox RS("Order_Number").Value

Rs.MoveNext

Wend

VB Script In built Functions

Command: InputBox.

Displays a prompt in a dialog box, waits for the user to input text or click a button, and returns the contents of the text box.

Syntax: InputBox(“Enter your name”)

Command: MsgBox.

Displays a message in a dialog box, waits for the user to click a button, and returns a value indicating which button the user clicked.

Syntax: MsgBox(“Hello World”)

String Functions:

StrComp: Returns a value indicating the result of a string comparison.

Usage: A=Strcmp(“Hello”,”Hello”)

A will have value 0 which means true.

InStr: Returns the position of the first occurrence of one string within another

Usage: val1="welcome to India"

val2="India"

val=InStr(1,val1,val2)

val will have value 12 . This means that the position of the word India in val1 is 12.

Split: Returns a zero-based, one-dimensional

array containing a specified number of substrings with respect to delimiter.

Usage:

Val=”appleXballXcatXdog”

Sval=Split(val,”X”,-1)

Now Sval(0) will have apple

Sval(1)=ball

Sval(2)=cat.

That is Split command will split the string based upon the delimiter specified.

Date and Time Functions:

Now: Returns the current date and time according to the setting of your computer's system date and time.

Usage:

Dim MyVar

MyVar = Now ' MyVar contains the current date and time.

DateAddf: Returns the number of intervals between two dates

Usage:

DiffADate = "Days from today: " & DateDiff("d", Now,"2/7/2008" )

MsgBox DiffADate

DiffADate will have the no of days between today and "2/7/2008"

DateAdd: Returns a date to which a specified time interval has been added.

Usage:

NewDate = DateAdd("m", 1, "31-Jan-95")

The NewDate will be “28-Feb-95”. One month latter than “31-Jan-95”

Day(now): This will return todays day alone. Like 21, 15 or 12

Hour(now): This will retun the current hour alone.

Tuesday, November 17, 2009

Disable Right click, Copy Paste from your webpage

Thinking of a way to make it more difficult for people to copy the contents of your blog? Here's a neat little JavaScript that will disable Copy and Paste.

<!-- Disable Copy and Paste-->
<script language='JavaScript1.2'>
function disableselect(e){
return false
}
function reEnable(){
return true
}
document.onselectstart=new Function (&quot;return false&quot;)
if (window.sidebar){
document.onmousedown=disableselect
document.onclick=reEnable
}
</script>

Insert the code between the <head> and </head> tag.



However, there is no guarantee way to prevent your contents from being stolen.The JavaScript above can be easily bypassed by an experience internet user. E.g. If the browser's JavaScript is disabled, the code will not work.

Monday, November 16, 2009

Coloring your Message Log

Sub CorrectRGBComponent(ByRef component)
component = aqConvert.VarToInt(component)
If (component <>
component = 0
Else
If (component > 255) Then
component = 255
End If
End If
End Sub

Function RGB(r, g, b)
Call CorrectRGBComponent(r)
Call CorrectRGBComponent(g)
Call CorrectRGBComponent(b)
RGB = r + (g * 256) + (b * 65536)
End Function

Sub Test
Set Attr = Log.CreateNewAttributes
Attr.FontColor = RGB(192, 0, 0)
Attr.BackColor = RGB(255, 255, 0)
' Passes the LogAttributes object to the Message function
Log.Message "My message", "", pmNormal, Attr
End Sub

Sunday, November 15, 2009

TestComplete: Working with Strings

This topic contains information about handling strings in VBScript and provides examples of operations that deal with strings. It contains the following sections:

Basics

Special characters

Getting the string length

Concatenating strings

Comparing strings

Accessing individual character of a string

Searching for characters and substrings

Getting a substring

Splitting strings

Removing extra spaces from a string

Replacing characters and substrings

Changing the letter case

Working with string lists

Basics

A String is a sequence of symbols or digits. Strings are among the most frequently used data types. Like any other data type, strings in TestComplete are represented as OLE-compatible variants. In VBScript, a sequence of literal characters, enclosed in double quotes ("), is recognized as a string. Single quotation marks (') are allowed within a string. To insert a double quotation mark into a string, it should be duplicated. The following is an example of string:

VBScript

str1 = "The brig was heading to Liverpool, when the captain noticed a ship."
str2 = "'Ahoy! Is there anyone?' - the captain cried."
str3 = """Nobody."" - was the answer."

To work with strings, TestComplete has a special scripting object - aqString. The object is available for all supported scripting languages, so you can use it to work with string values regardless of the chosen language.

Method, Property

Description

aqString.AddListItem

Adds a new item to a string list.

aqString.ChangeListItem

Changes the value of the string list item with the given index.

aqString.Compare

Compares two specified strings.

aqString.Concat

Concatenates two specified strings.

aqString.DeleteListItem

Removes an item with the given index from a string list.

aqString.Find

Searches for a substring within the given string. Use this method instead of the obsolete aqString.Contains.

aqString.Format

Generates a formatted string.

aqString.GetChar

Retrieves a single character from the input string.

aqString.GetLength

Returns the number of characters in a string.

aqString.GetListItem

Returns an individual item from the list passed through the input string.

aqString.GetListLength

Returns the number of items in the string list.

aqString.Insert

Inserts one string to another at the specified position.

aqString.ListSeparator

Specifies a character used to separate individual values in a list.

aqString.Quote

Encloses the specified string in quotes.

aqString.QuoteSymbol

Specifies a symbol used as a quotation mark.

aqString.Remove

Removes a number of characters from the input string.

aqString.Replace

Replaces all the occurrences of one substring with another substring.

aqString.SubString

Retrieves a substring from the input string.

aqString.ToLower

Converts the specified string to lower case.

aqString.ToUpper

Converts the specified string to upper case.

aqString.Trim

Removes spaces and control characters from the specified string.

aqString.Unquote

Converts a quoted string to an unquoted string.

Another scripting object that can be used to work with strings is aqConvert. This object has several methods that convert values of different types to a string and vice versa.

Method

Description

aqConvert.CurrencyToFormatStr

Converts a currency value to a string using the specified format settings.

aqConvert.CurrencyToStr

Converts a currency value to a string.

aqConvert.DateTimeToFormatStr

Converts the given date value to a string using the specified format.

aqConvert.DateTimeToStr

Converts the given date value to a string.

aqConvert.FloatToStr

Converts a floating-point value to a string.

aqConvert.IntToStr

Converts the given number into a string.

aqConvert.StrToCurrency

Converts the specified string to a currency value.

aqConvert.StrToDate

Converts the specified string to a date value.

aqConvert.StrToDateTime

Converts the specified string to a date/time value.

aqConvert.StrToFloat

Converts the specified string to a floating-point value.

aqConvert.StrToInt

Converts the specified string to an integer value.

aqConvert.StrToTime

Converts the specified string to a time value.

aqConvert.VarToStr

Converts the specified variant value to a string.

Furthermore, you can use native VBScript functions that operate with strings. A detailed description for these functions can be found at MSDN (the online version is available at http://msdn.microsoft.com). The table below only lists major functions:

Function

Description

Asc(string)

Returns the ASCII character code corresponding to the first letter in a string.

Chr(charcode)

Returns the character associated with the specified ANSI character code.

CStr(expression)

Returns an expression that has been converted to a variant of sub-type string.

Escape(charString)

Encodes a string so it only contains ASCII characters. Non-ASCII characters are replaced with %xx encoding, where xx is equivalent to the hexadecimal number representing the character.

InStr([startpos, ]string1, string2[, compare])

Returns the position of the first occurrence for one string within another.The search can start at a given position and use binary (compare=0) or text (compare=1) comparisons.

InStrRev(string1, string2[, start[, compare]])

Returns the position of an occurrence for one string within another, from the end of string. The search can start at a given position and use binary (compare=0) or text (compare=1) comparisons.

Join(list[, delimiter])

Returns a string created by joining a number of substrings contained in an array.

LCase(string)

Returns a string that has been converted to lowercase.

Left(string, length)

Returns a specified number of characters from the left side of a string.

Len(string | varname)

Returns the number of characters in a string or the number of bytes required to store a variable.

LTrim(string)

Returns a copy of a string without leading spaces.

Mid(string, start[, length])

Returns a specified number of characters from a string.

Replace(string, findstr, replacewith[, start[, count[, compare]]])

Returns a string in which a specified substring has been replaced with another substring a specified number of times.

Right(string, length)

Returns a specified number of characters from the right side of a string.

RTrim(string)

Returns a copy of a string without trailing spaces.

Space(number)

Returns a string consisting of the specified number of spaces.

Split(expression[, delimiter[, count[, compare]]])

Returns a zero-based, one-dimensional array containing a specified number of substrings.

StrComp(string1, string2[, compare])

Returns a value indicating the result of a string comparison.

String(number, character)

Returns a repeating character string of the length specified.

StrReverse(string)

Returns a string in which the character order of a specified string is reversed.

Trim(string)

Returns a copy of a string without leading and trailing spaces.

UCase(string)

Returns a string that has been converted to uppercase.

Unescape(charString)

Decodes a string encoded with the Escape function.

Special characters

In VBScript you can emulate any character by using the Chr function with the appropriate ASCII code. This also applies to special characters that are used to format string values. Alternatively, you can emulate control characters using native string constants. The table below lists the most frequently used special characters and their constants.

Description

Character sequence

Carriage return.

Chr(13) -- or -- vbCr

Line feed.
On Unix platforms it is interpreted as new line.

Chr(10) -- or -- vbLf

A combination of carriage return and line feed.
On Windows platforms it is interpreted as new line.

Chr(13)+Chr(10) -- or -- VbCrLf

New line.
Either a line feed character or a combination of carriage return and line feed.

vbNewLine

Form feed.

Chr(12) -- or -- vbFormFeed

Horizontal tab.

Chr(9) -- or -- vbTab

Vertical tab.

Chr(11) -- or -- vbVerticalTab

Friday, November 13, 2009

CPD User Names Module 12 November

Dim cpd
Dim frmCPDMain
Dim panel
Dim frmUserAddEdit
Dim tabControl
Dim tabPage
Dim textBox
Dim groupBox
Dim ultraGrid
Dim file
Dim i


Sub Test1

'TestedApps.CPD2.Run()
Call Aliases.Explorer.wndShell_TrayWnd.ReBarWindow32.MSTaskSwWClass.ToolbarWindow32.CheckItem("Inter-Agency Child Protection Database - [User Names and passwords]", True, False)
Set cpd = Aliases.CPD
Set frmCPDMain = cpd.frmCPDMain
Call frmCPDMain.StripMainMenu.Click("Tools|User Names and passwords")
aqUtils.Delay(1000)
Set panel = frmCPDMain.MdiClient.frmUserMaster.panel2
Set frmUserAddEdit = cpd.frmUserAddEdit
Set tabControl = frmUserAddEdit.tabControl1


set file=DDt.ExcelDriver("D:\book1.xls","Sheet1")
j=1
while Not(file.EOF())

Call panel.toolStripProtocol.ClickItem("New")
Call tabControl.ClickTab("User")
Set tabPage = tabControl.tpUser
Set textBox = tabPage.txtUserName
Call textBox.Click(41, 6)


textBox.wText = file.Value("User")
Call textBox.Keys("[Tab]")
Set textBox = tabPage.txtPassword
textBox.wText = file.Value("Password")
Call textBox.Keys("[Tab]")
tabPage.txtConfirmPassword.wText = file.Value("Password")
Set groupBox = tabPage.grpBx

Select Case j
Case 1
tabControl.tpUser.chkIsAdmin.wState = cbChecked

case 2
groupBox.chkAddEditData.wState = cbChecked
groupBox.chkDeleteData.wState = cbChecked
groupBox.chkDropDown.wState = cbChecked
groupBox.chkCustReports.wState = cbChecked
groupBox.chkExImData.wState = cbChecked
groupBox.chkImportSystemConfig.wState = cbChecked
groupBox.chkDbBackup.wState = cbChecked
frmUserAddEdit.btnSave.ClickButton

case 3
groupBox.chkAddEditData.wState = cbChecked
case 4
groupBox.chkDeleteData.wState = cbChecked
case 5
groupBox.chkDropDown.wState = cbChecked
case 6
groupBox.chkCustReports.wState = cbChecked
case 7
groupBox.chkExImData.wState = cbChecked
case 8
groupBox.chkImportSystemConfig.wState = cbChecked
case 9
groupBox.chkDbBackup.wState = cbChecked

case Else
MsgBox("Some Error occured with j")
exit Sub

end Select

frmUserAddEdit.btnSave.ClickButton
j=j+1
file.Next


Wend
MsgBox(CStr(j))

set file=DDt.ExcelDriver("D:\book1.xls","Sheet1")

while Not(file.EOF)
j=1


Call frmCPDMain.StripMainMenu.Click("Logout")

Set frmLogin = cpd.frmLogin
Set textBox = frmLogin.txtUserName
Call textBox.Click(74, 10)
textBox.wText = file.Value("User")
Call textBox.Keys("[Tab]")
Set textBox = frmLogin.txtPassword
textBox.wText = file.Value("Password")
Call textBox.Keys("[Tab]")
Call frmLogin.btnOK.Keys("[Enter]")
Set frmChangePassword = cpd.frmChangePassword
Set tabControl = frmChangePassword.tabControl1

' -------------------Code to change password when user logs in for first time------------------------------
Call tabControl.Keys("[Tab]")
Call tabControl.ClickTab("User")
Set tabPage = tabControl.tpUser
Call tabPage.txtUserName.Keys("[Tab]")
Set textBox = tabPage.txtOldPassword
textBox.wText = file.Value("Password")
Call textBox.Keys("[Tab]")
Set textBox = tabPage.txtNewPassword
textBox.wText = file.Value("Password")
Call textBox.Keys("[Tab]")
Set textBox = tabPage.txtConfirmPassword
textBox.wText = file.Value("Password")
Call textBox.Keys("[Tab]")
Call frmChangePassword.btnSave.Keys("[Enter]")
Call cpd.dlgInterAgencyChildProtectionDatabase.btnOK.Keys("[Enter]")

MsgBox("Stop Script")

Wend

End Sub

Set cpd = Aliases.CPD
Set frmCPDMain = cpd.frmCPDMain
set frmperson = frmCPDMain.MdiClient.frmPerson
Set ultraGrid = Aliases.CPD.frmCPDMain.MdiClient.frmPerson.ctrlChildView.ugChild


Sub Test2
Aliases.CPD.win
' Dim cpd
' Dim frmCPDMain
' 'TestedApps.CPD2.Run()
' Set cpd = Aliases.CPD
' Set frmCPDMain = cpd.frmCPDMain

'Call frmCPDMain.StripMainMenu.Click("Tools")


Call frmCPDMain.StripMainMenu.Click("Children")
Log.Message( export_import(True))
'Log.Message(delete_buttons(False))
Log.Message(is_admin())
Log.Message(restore_backup())
Log.Message(cust_dropdown())
Log.Message(cust_reports())
Log.Message(toolbar_new())
Log.Message(toolbar_edit())


'Log.Message("Export Import Menu bar" +CStr(exp_imp_menu()))







End Sub

'-------------------- Functions------------------------------------------------------

Function delete_buttons(flag)
flag2=""
' Checking toolbar delete

flag2=del_toolbar()
Log.Message("Toolbar Delete Button: "+CStr(flag2))
if flag <> flag2 Then
delete_buttons="........FAIL..........."
Exit Function
end if
'checking delete on right click
flag2=del_rightclk()
Log.Message("Right Click Delete Button: "+CStr(flag2))
if flag <> flag2 Then
delete_buttons=".........FAIL......."
Exit Function
end if
'checking delete on Registration Form
Call frmPerson.ctrlChildView.ugChild.ClickCellXY(1, 1, 55, 6)
Call cpd.frmChild_CaseData.pnlBase.flp.RegcustPanel.panel1.picBox.Click(31, 14)
flag2=del_regform()
Log.Message("Registration Form Delete Button: "+CStr(flag2))
if flag <> flag2 Then
delete_buttons=".......FAIL.........."
Exit Function
end if
cpd.frmPersonNew.Close
'checking Delete on Case Data Form
Call Aliases.CPD.frmChild_CaseData.pnlBase.flp.custPanel0.panel1.picBox.Click()
flag2=del_casedata_toolbar()
Log.Message("Case Data Form Delete Button: "+CStr(flag2))
if flag <> flag2 Then
delete_buttons=".........FAIL........."
Exit Function
end if
Aliases.CPD.frmCaseData.close()
delete_buttons="........PASS........"

end Function


Function export_import(flag)

flag2=""

'Checking Export import in Menu
Call frmCPDMain.StripMainMenu.Click("Tools")
flag2=exp_imp_menu()
Log.Message("Export Import Menu bar"+CStr(flag2))
if not flag = flag2 Then
MsgBox(CStr(flag)+CStr(flag2)+"Hi")
export_import="FAIL"
Exit Function
end if


'checking Export Import in Tool Bar
flag2=exp_toolbar()
Log.Message("Export In Tool bar"+CStr(flag2))
if flag <> flag2 Then
export_import="FAIL"
Exit Function
end if
flag2=imp_toolbar()
Log.Message("Import In Tool bar"+CStr(flag2))

if flag <> flag2 Then
export_import="FAIL"
Exit Function
end if
flag2=exptoexcel_toolbar()
Log.Message("Export to excel Toolbar"+CStr(flag2))
if flag<>flag2 Then
export_import="FAIL"
Exit Function
end if
flag2=trnsfr_toolbar()
Log.Message("Transfer in Toolbar"+CStr(flag2))
if flag <> flag2 Then
export_import="FAIL"
Exit Function
end if
flag2=refral_toolbar()
Log.Message("Referal in Toolbar"+CStr(flag2))
if flag <> flag2 Then
export_import="FAIL"
Exit Function
end if
'Checking Export Import in Tracing Request
flag2=export_tr()
Log.Message("Export in Toolbar Tracing Request "+CStr(flag2))
if flag <> flag2 Then
export_import="FAIL"
Exit Function
end if
flag2=import_tr()
Log.Message("Import in Toolbar Tracing Request "+CStr(flag2))
if flag <> flag2 Then
export_import="FAIL"
Exit Function
end if
flag2=exportoexcel_tr()
Log.Message("Export To Excel in Toolbar Tracing Request "+CStr(flag2))
if flag <> flag2 Then
export_import="FAIL"
Exit Function
end if

'checking Record Matching
flag2=exportoexcel_RM()
Log.Message("Export to Excel in Record Matching"+CStr(flag2))
if flag <> flag2 Then
export_import="FAIL"
Exit Function
end if

export_import="PASS"
end Function





Function exp_imp_menu()
'---- i is a global variable ----
i=1
MsgBox(cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(3).Text)

While ((cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(3).Text <> "Import") AND i<20)
'MsgBox(cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(3).Text)
'MsgBox(cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(4).Text)
i=i+1
Wend

if (cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(3).Text = "Import" And cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(4).Text = "Export") then
Call frmCPDMain.StripMainMenu.Click("Tools")
if (cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(3).Visible = True And cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(4).Visible = True) then
exp_imp_menu=True
Else
exp_imp_menu=False
end If
Else
exp_imp_menu=False
End if


end Function


Function exp_toolbar()

exp_toolbar=aqObject.CompareProperty(frmPerson.toolStripChild.wEnabled("Export"), cmpEqual, True, False)

end Function

Function imp_toolbar()
imp_toolbar =aqObject.CompareProperty(frmPerson.toolStripChild.wEnabled("Import"), cmpEqual, True, False)

End Function

Function exptoexcel_toolbar()
exptoexcel_toolbar=CompareProperty(frmPerson.toolStripChild.wEnabled("Export to Excel"), cmpEqual, True, False)
end Function

Function trnsfr_toolbar()
trnsfr_toolbar=aqObject.CompareProperty(frmPerson.toolStripChild.wEnabled("Transfer"), cmpEqual, True, False)
end Function

Function refral_toolbar()
refral_toolbar = aqObject.CompareProperty(frmPerson.toolStripChild.wEnabled("Referral"), cmpEqual, True, False)
end Function

Function export_cd_toolbar()

export_cd_toolbar=CompareProperty(CPD.frmCaseData.toolStripManageForm.wEnabled("Export"),cmpEqual,True, False)

end Function

Function import_cd_toolbar()

import_cd_toolbar=CompareProperty(CPD.frmCaseData.toolStripManageForm.wEnabled("Import"),cmpEqual,True, False)

end Function

Function open_cd_form()
Call frmCPDMain.StripMainMenu.Click("Children")
Call frmPerson.ctrlChildView.ugChild.ClickCellXY(1, 1, 55, 6)
Call Aliases.CPD.frmChild_CaseData.pnlBase.flp.custPanel0.panel1.picBox.Click()

end Function

Function close_cd_form()
Aliases.CPD.frmCaseData.close()
End Function

' To Check Export Button on Tracing request
Function export_tr()
Call frmCPDMain.StripMainMenu.Click("Tracing Request")
export_tr=aqObject.CompareProperty(frmPerson.toolStripChild.wEnabled("Export"), cmpEqual, True, False)
end Function

Function import_tr()
import_tr=aqObject.CompareProperty(frmPerson.toolStripChild.wEnabled("Import"), cmpEqual, True, False)
end Function

Function exportoexcel_tr()
exportoexcel_tr = aqObject.CompareProperty(frmPerson.toolStripChild.wEnabled("Export to Excel"), cmpEqual, True, False)
end Function


' To check button in Record Matching
function exportoexcel_RM()
Call frmCPDMain.StripMainMenu.Click("Record Matching")
exportoexcel_RM=aqObject.CompareProperty(frmPerson.toolStripChild.wEnabled("Export to Excel"), cmpEqual, True, False)
end Function



Function restore_backup()
' i=1
' While ((cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(3).Text <> "Backup") AND i<20)
' MsgBox(cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(3).Text)
' MsgBox(cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(4).Text)
' MsgBox(CStr(i))
' i=i+1
' Wend
'Call frmCPDMain.StripMainMenu.Click("Tools")


if (cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(0).Text = "Backup" And cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(1).Text = "Restore") then
Call frmCPDMain.StripMainMenu.Click("Tools")
if (cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(0).Visible = True And cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(1).Visible = True) then
restore_backup = True
Else
restore_backup = False
end if
Else
restore_backup = False
End if

end Function


Function cust_dropdown()

if cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(7).Text = "Customize Drop-down Values" then
cust_dropdown = True
Else
cust_dropdown = False
end if

end Function

Function cust_reports()
if cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(11).Text = "Customize Reports" then
cust_reports=True
Else
cust_reports= False
end If
end Function

Function is_admin ()

if (Trim((cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(8).Text) = "User Names and passwords" And Trim(cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(13).Text) = "Set Time Scale Targets")) then
is_admin = True
Else
is_admin= False

Log.Message(CStr(cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(8).Text))
Log.Message(CStr(cpd.WinFormsObject("ToolStripDropDownMenu", "", i).Items.Item_2(13).Text))

end If
end Function

' Checking Delete Button on Children - Tool Bar
Function del_toolbar()
del_toolbar=aqObject.CompareProperty(frmPerson.toolStripChild.wEnabled(2), cmpEqual, True, False)
End Function

' Checking Delete function on Registration Form
Function del_regform()
del_regform = CompareProperty(CPD.frmPersonNew.ugTab.ugTabPageChild.toolStripManageForm.wEnabled("Delete"), cmpEqual, True, False)
end Function

' Checking Delete button ON - Case data Tool bars :
Function del_casedata_toolbar()
del_casedata_toolbar = CompareProperty(CPD.frmCaseData.toolStripManageForm.wEnabled("Delete"),cmpEqual,True, False)
end Function

' Checking Delete Button on Right Click menu
Function del_rightclk()

Call frmCPDMain.StripMainMenu.Click("Children")
Call ultraGrid.ClickCellRXY(3, "Status", 28, 6)

if CPD.WinFormsObject("ContextMenuStrip", "", 1).Items.Item_2(1).text= "Delete" then
del_rightclk=True
Else
del_rightclk=False
end if
end Function



Function toolbar_new()
toolbar_new = aqObject.CompareProperty(frmPerson.toolStripChild.wEnabled(0), cmpEqual, True, False)

end Function

Function toolbar_edit()

toolbar_edit = aqObject.CompareProperty(frmPerson.toolStripChild.wEnabled(1), cmpEqual, True, False)

end Function

Thursday, November 5, 2009

Accessing Embeded Grid controls

//Code to access Columns

DIGridControl.DisplayLayout.Bands.Item(0).Columns.Item(0)

//Code to access Rows

DIGridControl.DisplayLayout.Rows.Item(0).Cells.Item(4).set_Value("check")

Wednesday, November 4, 2009

Using third party Tab Control

Used in the function below :
Following code will be helpful if you are using any non microsoft/Java controls say Infrajestics :This function will click tabs

sub linkform_click(tabcontrol, linkformname)
dim I
for I = 0 to tabControl.Tabs.Count-1
if tabControl.VisibleTabs.get_Item(I).Text.OleValue= cstr(linkformname) then
tabControl.VisibleTabs.get_Item(I).Selected = true
end If
Next
end Sub

Sunday, November 1, 2009

SQL Injection / Hacking security

With SQLServer/ Mysql server running at the background try:

abc' or 1=1--

Enter above line of code in username and hit login, you might get shocked when you actually login to the site with a valid user.

For testers this is an important point to ensure a secure application.
And for hackers a boon!! ;)