10-05-2012, 08:42 AM
Hi everyone! I'm new in this forum and a very avid Qtp learner. I been trying to learn create a framework here it's working fine except my Excel loop is not working, it's just keep overwriting on the same row and column. Please anypne can help me out .
Code:
Environment.LoadFromFile"C:\Documents and Settings\Administrator\My Documents\Survey_Monkey.xml"
Executefile Environment.value("Env_Functionpath")
Repositoriescollection.Add Environment.value("Env_objrep")
i=2
For i = 2 to 4
set objExcel=createobject("Excel.application")
objExcel.workbooks.open Environment.value("Excel_path")
objExcel.application.visible=True
set objExcelsheet=objExcel.activeworkbook.worksheets("sheet1")
username=Fnrandomusername
Password=Environment.value("Env_Password")
Retype_password=Environment.value("Retype_Password")
Email_id=FnrandomEmailid
Fnlaunch_application
wait 2
Browser("Sign up for a FREE SurveyMonke").Page("Sign up for a FREE SurveyMonke").WebEdit("UserName").Set username
wait 3
Browser("Sign up for a FREE SurveyMonke").Page("Sign up for a FREE SurveyMonke").WebEdit("Password").Set Password
wait 3
Browser("Sign up for a FREE SurveyMonke").Page("Sign up for a FREE SurveyMonke").WebEdit("PassConfirm").Set Retype_password
Browser("Sign up for a FREE SurveyMonke").Page("Sign up for a FREE SurveyMonke").WebEdit("ContEmail").Set Email_id
Browser("Sign up for a FREE SurveyMonke").Page("Sign up for a FREE SurveyMonke").WebElement("Sign Up").Click
wait 5
If Browser("Sign up for a FREE SurveyMonke").Page("Welcome to SurveyMonkey!").Link("Sign Out").Exist then
objexcelsheet.cells(2,5).value="Passed"
objexcelsheet.cells(2,2).value=Fnrandomusername
objexcelsheet.cells(2,7).value=FnrandomEmailid
objexcelsheet.cells(2,6).value="Registration_successful"
else
objexcelsheet.cells(2,5).value="Failed"
objexcelsheet.cells(2,6).value="Resistration_Failed"
end if
browser("index:=0").page("index:=0").CaptureBitmap"c:/Login_verification1.png",true
wait 3
Browser("Sign up for a FREE SurveyMonke").Page("Welcome to SurveyMonkey!").Link("Sign Out").Click
FnClose_browser
i=2+1
next
'Browser("Welcome to SurveyMonkey!").Page("Welcome to SurveyMonkey!").Link("Sign Out").Click
'objexcelsheet.cells(2,2).value=username
objexcelsheet.cells(2,3).value=Password
objexcelsheet.cells(2,4).value=Retype_password
objExcel.activeworkbook.save
objExcel.activeworkbook.close
objExcel.application.quit
set objExcel=nothing
set objExcelsheet=nothing