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:
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