pls tell me how will you write the vb script in QTP for
DataDriven test from Excel sheet for multiple userid and
password explain with example

Answer Posted / deven

'Data driven Frame work script
Option Explicit
'define constants for web URL and browser name
executefile "C:\TestAutomation\openTAPS\Lib\Constants.vbs"
executefile "C:\TestAutomation\Common\Lib\UtilityFunctions.v
bs"
executefile "C:\TestAutomation\Common\Lib\SendingEmail.vbs"
executefile "C:\TestAutomation\openTAPS\Classes\Functions.vb
s"
'declare variables
Dim iRowcount, i, Username, Password
'
datatable.AddSheet("dtInvalidLogin")
'ValidLogin is the sheet name
datatable.ImportSheet "C:\TestAutomation\openTAPS\Data\TestD
ata.xls", "InValidLogin", "dtInvalidLogin"

'Get row count from datatable
iRowcount = datatable.GetSheet("dtInvalidLogin").GetRowCount

For i = 1 to iRowcount

'functions
OpenApp()

'set username and password
Username = trim(datatable.Value
("Username", "dtInvalidLogin"))
Password = trim(datatable.Value
("Password", "dtInvalidLogin"))

Login Username, Password

'Verification: check username should display on home page
If Browser("opentaps CRM").Page("opentaps CRM").WebElement
("DemoCSR").GetROProperty("outertext")=Username Then
'object.method to report events in HP Run Results
Viewer that Login is successful or not
'EventStatus - micPass shows under Results
'StepName - ValidLogin shows under Object
'UserName Login Successful shows under Details
reporter.ReportEvent micPass, "ValidLogin",
Username& " Login not successful"
WriteToFile "C:\QTP\TestAutomation\openTAPS\Logs\Tes
tResults.txt", Username & " Login successful"
Else
reporter.ReportEvent micFail, "ValidLogin",
Username& " Login successful"
WriteToFile "C:\QTP\TestAutomation\openTAPS\Logs\Tes
tResults.txt", Username & " Login not successful"
End If

'Logout
Browser("My Home | opentaps CRM").Page("My Home | opentaps
CRM").Link("Logout").Click @@ hightlight id_;_Browser("My
Home | opentaps CRM").Page("My Home | opentaps CRM").Link
("Logout")_;_script infofile_;_ZIP::ssf1.xml_;_

'close app
CloseApp()

datatable.SetNextRow
Next
'Gmail
SendMail "21deven@gmail.com", "jinideveloper@gmail.com", "QT
PTest Results", "Please find my qtp test results"
'Outlook
'SendMail("21deven@gmail.com", "QTPTest Results", "Please
find my qtp test
results" , "C:\QTP\TestAutomation\openTAPS\Logs\TestResults.
txt")

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to automate a script in mainframes environment? I have the terminal emulator Add in. Describe in detail.

1920


For which type of projects the iterative model is not suitable?

1655


Explain the types of object repository?

733


Hoe can we do retesting using functions please give the code for it using login page

1741


if numbers are always changing write a script for that

3743


describe some problems that u had with automating testing tool?

1576


How can I change object description or check point values in qtp?

743


If I change the property value at runtime is it effect is object repository?

824


What is the script for database check point, bitmapchek point, regular expression ?

1784


1.How to record ,capture and also script to capture the close buttons. 2.How to record ,capture and also script to capture the options ---File ->save and File ->close in a browser and PDF files. 3.How to compare the Excel sheet values in a report using QTP scripting. 4.How to compare 2 PDf reports using QTP scripts as well reording. 5.How to compare 2 Excel reports using QTP scripts as well reording. 6.How to save a PDF report to a folder and then translate the report to an Excel type of report and compare that Excel Report with an other excel report. Please clarify me

1820


How you know that a test case is a regression test case

3458


What is Test Fusion Report in QTP?

861


Tell some commonly used Excel VBA functions?

797


Does quicktest professional (qtp) is unicode compatible?

742


Explain quicktest professional testing process?

730