Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Read from excel.
#1
Solved: 10 Years, 10 Months 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


Messages In This Thread
Read from excel. - by hpham - 06-25-2008, 09:27 AM
RE: Read from excel. - by Ankur - 06-26-2008, 12:13 AM
RE: Read from excel. - by hpham - 06-26-2008, 01:07 PM

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,177 07-10-2017, 04:20 PM
Last Post: rajeevk7
  How to read and write in excel through QTP script shwetha_m 5 29,320 03-14-2014, 02:58 PM
Last Post: venkatesh9032
  Unable to read the data from excel file attiliv 1 2,875 03-26-2013, 08:02 AM
Last Post: sams001

Forum Jump:


Users browsing this thread: 1 Guest(s)