Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Read from excel.
#1
Solved: 10 Years, 9 Months, 1 Week ago
Hi everybody,
I want to automate function login, with two field username and password. If I use datatable, the script is successful. Then I want to read username and password from an excel file, then in the first loop, QTP recognizes these two fields, but in second loop, it doesn't recognize. I know why, cause the page is now not the login page, but I don't know how to correct it, pls help me. Here is my script:

Code:
Option Explicit
Dim filepath, sheet,rownum, row,columnnum, column,username, password, ExcelObj
filepath= "C:\test.xls"

Set ExcelObj = CreateObject("Excel.Application")
ExcelObj.DisplayAlerts = 0
ExcelObj.Workbooks.Open filePath, false, true '//opens the excel from desired path

Set sheet = ExcelObj.ActiveWorkbook.Worksheets(1)
rownum = sheet.UsedRange.Rows.count
columnnum = sheet.UsedRange.Columns.count

For row = 2  to rownum
    username = sheet.Cells(row,1)
    password = sheet.Cells(row, 2)
    Browser("STT Info -tiedotepalvelu").Page("STT Info -tiedotepalvelu").WebEdit("username").Set username
    Browser("STT Info -tiedotepalvelu").Page("Internal Site :: Press").WebEdit("password").SetSecure password
    Browser("STT Info -tiedotepalvelu").Page("STT Info -tiedotepalvelu").WebButton("Kirjaudu").Click

    Browser("STT Info -tiedotepalvelu").Page("Internal Site :: Press_2").Check CheckPoint(username)
    Browser("STT Info -tiedotepalvelu").Page("Internal Site :: Press_2").Sync

Next
Set sheet = Nothing
ExcelObj.Workbooks(1).Close
ExcelObj.Quit
Set ExcelObj = Nothing
Reply
#2
Solved: 10 Years, 9 Months, 1 Week ago
You have your answer in the question itself "cause the page is now not the login page" . While iterating always make sure that start and end conditions( in this case login page) are same.

Before Next add the line of code which takes you to your application.
Want to fast track your QTP/UFT Learning? Join our UFT Training Course
Reply
#3
Solved: 10 Years, 9 Months, 1 Week ago
Thanks a lot, Ankur.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Want to read the data from excel and set read value in the JavaTable rajeevk7 0 2,172 07-10-2017, 04:20 PM
Last Post: rajeevk7
  How to read and write in excel through QTP script shwetha_m 5 29,270 03-14-2014, 02:58 PM
Last Post: venkatesh9032
  Unable to read the data from excel file attiliv 1 2,859 03-26-2013, 08:02 AM
Last Post: sams001

Forum Jump:


Users browsing this thread: 1 Guest(s)