Tricentis Tosca 16.0 Released on Feb-2023 ----- UFT has been upgraded from UFT 15.0.1 to UFT One 15.0.2, Beginning at November 2020.

Thursday, 25 April 2019

Fetching Test Data from Excel Sheet and Setting into Application Fields.

Option Explicit
Dim Sheetpath, FsoObject, Excelsheet, rowNumber, UserId,Pwd, SheetCells, Row_Count, i
Sheetpath="D:\testdata.xlsx"
Set FsoObject=CreateObject("Excel.Application")
FsoObject.Workbooks.Open Sheetpath
Set Excelsheet=FsoObject.ActiveWorkbook.Worksheets("Sheet1")
Row_Count=FsoObject.ActiveSheet.UsedRange.Rows.Count
For i=1 to Row_Count
   UserId=FsoObject.Cells(i,1).value
   Pwd =FsoObject.Cells(i,2).value

   Browser("...").Page("...").WebEdit("UserId").Set UserId
   Browser("...").Page("...").WebEdit("Password").Set Pwd
   Browser("...").Page("...").WebButton("Login").Click
   LoginText=Browser("...").Page("...").WebEdit("text").GetROProperty("text")
   Excelsheet.Cells(i,3)=LoginText
Loop
FsoObject.ActiveWorkbook.Save
FsoObject.Application.Quit
Set FsoObject=nothing

Fetching Test Data from DataBase  and Setting into Application Fields.

Option Explicit
Dim path, app, Sheets, row, UserId, Pwd
Set app=CreateObject("ADODB.Connection")
Set rec=CreateObject("ADODB.Recordset")
app.Open "Provider=SQLQLEDB;Server=.\SQLEXPRESS;UserId=test;Password=P@123;Database =AUTODB"
rec.LockType=3
rec.Open "Select * from LoginData",app

Do while rec.EOF<> True
   UserId=rec.Fields.Item("UserName")
   Pwd=rec.Fields.Item("PassWord")
   Browser("...").Page("...").WebEdit("UserId").Set UserId
   Browser("...").Page("...").WebEdit("Password").Set Pwd
   Browser("...").Page("...").WebButton("Login").Click
   LoginText=Browser("...").Page("...").WebEdit("text").GetROProperty ("text")
   rec.Fields.Item("StatusMessage").Value=LoginText
   rec.Update
   rec.MoveNext
Loop

app.Close
rec.Close
Set app=
Nothing
Set rec=Nothing

No comments:

Post a Comment

Note: only a member of this blog may post a comment.