Thursday, February 28, 2013

Regular Expression In Decriptive Programming

*************************************************************************************
Regular Expression In Decriptive Programming :
*************************************************************************************

In Descriptive Programming by default the properties will be treated as regular expression when you added to description object


Set oDescription=Description.Create
oDescription("micclass").value= "Browser"
oDescription("openurl").value=
http://www.google.co.in


Here in this URL property there are three dots (.) which can be treated as regular expressions. These dots will work as regular expressions because by default the property values will be treated as regular expressions.

If we don't Want make default regular expression, set the regularexpression property to false to treat "http://www.google.co.in" as a literal string.

Set oDescription=Description.Createo
Description("micclass").value= "Browser"
oDescription("openurl").value= "
http://www.google.co.in"
oDescription("openurl").regularexpression = False

 

QTP 11.5 Features

***********************************************************
Unified Functional Testing (UFT) = Quick Test Pro (QTP) + Service Test (ST)
************************************************************
This is going to be a major change on how we see QTP. Going forward, QTP and Service Test will be a part of UFT 11.5 software. Acc. to HP, this has been done to serve end-to-end testing needs. QTP (GUI testing tool) and Service Test (API testing tool) will be available from a single interface, so you need not download two separate tools from now on.
*************************************************************
Multiple script Debugging.
*************************************************************
This was a much needed and requested feature. You will now be able to debug two or more scripts at the same time from within UFT’s IDE.
***************************************************************
PDF Checkpoints
***************************************************************
You can now directly compare PDF files and run checkpoints on them.
***************************************************************
Support Open Source CI Systems
***************************************************************
HP UFT 11.5 will support open source Continuous Integration like Jenkins and Hudson. [For people with non-development background - CI is a practice normally used in a multi-developer environment where all developer codebases are merged with the main codebase several times a day]
**************************************************************
Mobile Testing Support
***************************************************************
Realizing the ‘explosive’ growth of mobile (smart-phones + tablets) platform, HP is putting a lot of focus on this new age tech. UFT 11.5 will provide a better support for mobile testing. With the help of HP UFT Mobile, HP claims that you will be able to create mobile platform agnostic scripts; hence a script created for iOS would be expected to work for Android. The mobile application testing solution will support emulators as well as real devices. The real devices can be sourced from the public cloud of shared real devices and/or private cloud of dedicated real devices.

Monday, February 11, 2013

.net factory in QTP

function GetPassword()




Set objForm = DotNetFactory.CreateInstance("System.Windows.Forms.Form", "System.Windows.Forms")

Set objBtn1 = DotNetFactory.CreateInstance("System.Windows.Forms.Button", "System.Windows.Forms")

Set objLbl = DotNetFactory.CreateInstance("System.Windows.Forms.Label", "System.Windows.Forms")

Set objPassword = DotNetFactory.CreateInstance("System.Windows.Forms.TextBox", "System.Windows.Forms")
Set objLbl2 = DotNetFactory.CreateInstance("System.Windows.Forms.Label", "System.Windows.Forms")
Set objUserName = DotNetFactory.CreateInstance("System.Windows.Forms.TextBox", "System.Windows.Forms")
Set objRegion = DotNetFactory.CreateInstance("System.Windows.Forms.ComboBox", "System.Windows.Forms")
objForm.Left=500
objForm.Top=250
objForm.Height=275
objUserName.Top=40
objUserName.Left=100
objPassword.Top=70
objPassword.Left=100
objPassword.UseSystemPasswordChar=True
objForm.CancelButton = objBtn1
objLbl.text = "User Name"
objLbl.Top=40
objLbl.Width=80
objLbl.left=20
objLbl2.text="Password"
objLbl2.Top=70
objLbl2.Left=20
objLbl2.Width=80
objRegion.Items.add "DEV"
objRegion.Items.add "QA"
objRegion.Items.add "PROD"
objBtn1.text = "OK"
objBtn1.Top=170
objBtn1.Left=95
objBtn1.Width=120
objBtn1.Height=30
objUserName.TabIndex=1
objPassword.TabIndex=2
objRegion.TabIndex=3
objBtn1.TabIndex=4
objForm.controls.add(objLbl)
objForm.controls.add(objLbl2)
objForm.controls.add(objUserName)
objForm.controls.add(objBtn1)
objForm.controls.add(objPassword)
objForm.controls.add(objRegion)
objForm.StartPosition = CenterScreen
objForm.Text = "Regression testing"
objForm.showDialog
Environment.Value("vUserName") =objUserName.text
Environment.Value("vPassword")=objUserName.text
Environment.Value("vRegion")=objRegion.Text

End function

Working With Word Document

*****************************************************************************************************
Working with Word Docuument:
*****************************************************************************************************
 Create a word Document:
*****************************************************************************************************
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
'Documents collection includes all of the open documents.
'Add method is used to create a blank document.
'Document object returned by Add method is assigned to a variable, objDoc.
Set objDoc = objWord.Documents.Add()
*****************************************************************************************************
Open a word Document file:
*****************************************************************************************************
Set wrd = CreateObject("Word.Application")
wrd.Visible = True
wrd.Documents.Open "D:\Temp.doc"
Set wrd.Nothing
*****************************************************************************************************
Writting a Text in Word Application:
*****************************************************************************************************
Set oWord = CreateObject("Word.Application")
oWord.Visible = True
Set oDoc = oWord.Documents.Add()
Set oSelection = oWord.Selection
'Selection property represents selected area in a document or an insertion point
oSelection.TypeText = "Sample Text"
*****************************************************************************************************
Formatting the text in the word document:
*****************************************************************************************************
Set oWord = CreateObject("Word.Application")
oWord.Visible = True
Set oDoc = oWord.Documents.Add()
Set oSelection = oWord.Selection
'Setting the Font Name
oSelection.Font.Name = "Arial"
'Setting the Font Size
oSelection.Font.Size = "20"
'Setting the type face to Bold
oSelection.Font.Bold = True
oSelection. ParagraphFont.Alignment = 1
'0 - Aligns text to Left, 1- Aligns text to center
'2 - Aligns text to Right, 3 - Justify the text
oSelection.TypeText = "Add your text here"
*****************************************************************************************************
Replacing a Word in Word Document:
*****************************************************************************************************
Set oWord = CreateObject("Word.Application")
Set oDoc = oWord.documents.Open("C:\WordDocument.docx")
Set oWords = oDoc.Words
For word = 1 to oWords.Count
oWords.Item(word).Text = Replace(oWords.Item(word).Text, "sample","New word")
Next
oDoc.Save
oDoc.Close
oWord.Quit
Set oDoc = Nothing
Set oWords = Nothing
Set oWord = Nothing
*****************************************************************************************************
Saving the Word Document:
*****************************************************************************************************
To save a single doucument use the Save method with the Document object. The following insturction saves the document named "Sales.doc"
Documents("Sales.doc")Save
You can save all open documents by applying Save method to the Documents collection. The following instruction saves all open documents.
Documents.Save
'To save to a new location use "SaveAs" else use "Save" method to save it on default location
oDoc.SaveAs("c:\MyDoc.doc")
*****************************************************************************************************
Closing the Word Document:
*****************************************************************************************************
oWord.Quit
 *****************************************************************************************************
Working with Tables:
*****************************************************************************************************
Set oWord = CreateObject("Word.Application")
oWord.visible = True
Set oDoc = oWord.Documents.Add()
Set oRange = oDoc.Range()
oDoc.Tables.Add oRange,3,3
Set oTable = oDoc.Tables(1)
For Row = 1 to 3
For Column = 1 to 3
oTable.Cell(Row,Column).Range.Text = Row&" Row, "&Column&" Column"
Next
Next
'Make the First Row Data to Bold
oTable.Rows.Item(1).Range.Font.Bold = True
'Makes the First Row Data to Italic
oTable.Rows.Item(1).Range.Font.Italic = True
'Changes the font size
oTable.Rows.Item(1).Range.Font.Size = 12
'Sets the width of the Column
oTable.Columns.Item(1).SetWidth 100,0
*****************************************************************************************************
Open and Append Text to a Document:
*****************************************************************************************************
Dim oWord
Set oWord = CreateObject("Word.Application")
oWord.Documents.Open "c:\text.doc"
oWord.Selection.TypeText "Text which is appended to existing document"
oWord.ActiveDocument.Save
oWord.Quit
Set oWord = Nothing
Selection property by default appends the text at the beginning only. To put the statements for selection at the end before entering the text, use the below cose.
Dim oWord
Set oWord = CreateObject("Word.Application")
oWord.Documents.Open "c:\text.doc"
oWord.Selection.EndKey 6,0
oWord.Selection.TypeText "Text which is appended to existing document"
oWord.ActiveDocument.Save
oWord.Quit
Set oWord = Nothing
*****************************************************************************************************
Prints the word document:
*****************************************************************************************************
Dim oWord
Set oWord = CreateObject("Word.Application")
oWord.Documents.Open "c:\test.docx"
oWord.Activedocument.PrintOut
oWord.Quit
Set oWord = Nothing

QTP Framework

************************************************************************************************
Framework:
************************************************************************************************
A set of guidelines like coding standards , test-data handling , object repository treatment etc... which when followed during automation scripting produce beneficial outcomes like increase code re-usage , higher portability , reduced script maintenance cost etc. Mind you these are just guidelines and not rules; they are not mandatory and you can still script without following the guidelines


Basically QTP supports three kind of framework i
1)     Linear Framework
2)     Modular driven framework
3)     Keyword Driven Framework.
************************************************************************************************
Linear Framework
************************************************************************************************
                It deals with individual script which is recorded under one Action and running individual. I think we all done this thing in very first when we get the QTP but I’m very sure, not all one know that we created and executed the test under Linear Framework. Anyway this is not big deal. I was also not aware when I get the QTP first time. So this is very simple and easy way to create the test by navigating through the application. But by using this method there are some limitations which we can not cross. Sometime when we test some business processes in one application, we may feel that some operations we repeat in all Linear Framework Script. To handle this situation we go with Modular Framework which solves this kind of problem by dividing the single test in multiple part or module.
************************************************************************************************
In modular framework
************************************************************************************************
                  Tester basically divides the test in different parts which give the facility to use the different part of scripts in any tests. That solves the many problem of repeataion of test and gives the facility to make the script reusable? So in one sentence, Division of Linear Framework script in different parts called Modular Framework.
************************************************************************************************
keyword driven framework
************************************************************************************************
           Tester should know the basic of programming because it deals with function. In programming, Function is an important part of programming as they allow you to create chunks of code that performs a specific task. Basically we create the functions in the one test and calling these functions as keyword in other tests therefore we are calling keyword driven framework. This is very important and useful framework to deal and handle many critical tasks in testing through QTP.