Forum Discussion
Ruhul_Ikram
8 years agoOccasional Contributor
Hi,
I have similar question.
In Keyword Test, when I do data driven and covert to script I can mention which row to run or from specific row specific row, see below example:
function End_to_End_Referral_Specialist() { //Launches the specified browser and opens the specified URL in it. Browsers.Item(btFirefox).Run(Project.Variables.EndtoEnd_Complaint3.Value("URL")); //Maximizes the 'BrowserWindow2' window. Aliases.browser.BrowserWindow2.Maximize(); Project.Variables.EndtoEnd_Complaint3.Reset(); var RecordIdx; for(RecordIdx = 1; RecordIdx <= 16; RecordIdx++) { Log.AppendFolder(Project.Variables.EndtoEnd_Complaint3.Value("Test Name"), Project.Variables.EndtoEnd_Complaint.Value("Description")); //Sets the text KeywordTests.End_to_End_Referral_Specialist.Variables.EndtoEnd_Complaint("Username") in the 'textboxUsername' text editor. Aliases.browser.formLoginform.textboxUsername.SetText(Project.Variables.EndtoEnd_Complaint.Value("Username")); //Sets the text KeywordTests.End_to_End_Referral_Specialist.Variables.EndtoEnd_Complaint("Password") in the 'passwordboxPassword' text editor. Aliases.browser.formLoginform.passwordboxPassword.SetText(Project.Variables.EndtoEnd_Complaint.Value("Password")); //Clicks the 'submitbuttonLogin' control. Aliases.browser.formLoginform.submitbuttonLogin.ClickButton(); Aliases.browser.linkLogout.Click(); Log.PopLogFolder(); Project.Variables.EndtoEnd_Complaint3.Next(); }
but when I try to do it custom functions it only loops through 1st row 4 times, see below codes:
function DataSheet (tab){
// Creates a driver
DDT.ExcelDriver("C:\\AutomationFiles\\test.xls", tab, true);
// Iterates through records
ProjectSuite.Variables.TestName = DDT.CurrentDriver.Value("Test Name");
ProjectSuite.Variables.TestDescription = DDT.CurrentDriver.Value("Description");
ProjectSuite.Variables.Username = DDT.CurrentDriver.Value("Username");
//Log.Message(ProjectSuite.Variables.Username)
ProjectSuite.Variables.Password = DDT.CurrentDriver.Value("Password");
//Log.Message(ProjectSuite.Variables.Password)
DDT.CurrentDriver.Next();
// Close the driver
DDT.CloseDriver(DDT.CurrentDriver.Name);
}
function excelSmokeTest() { //check Cust_Variables to see what browser and env we're testing, open that browser CheckBrowser(ProjectSuite.Variables.URL); var RecordIdx; for(RecordIdx = 1; RecordIdx <= 4; RecordIdx++) { DataSheet('E-T-E') Log.AppendFolder(ProjectSuite.Variables.TestName, ProjectSuite.Variables.TestDescription) //input username/pw to login login(ProjectSuite.Variables.Username,ProjectSuite.Variables.Password); MAXe_logout(); Log.PopLogFolder(); } }
Not sure what am I missing and if I run below code it fails:
function DataSheet (tab){ // Creates a driver DDT.ExcelDriver("C:\\AutomationFiles\\test.xls", tab, true); // Iterates through records while (! DDT.CurrentDriver.EOF()){ ProjectSuite.Variables.TestName = DDT.CurrentDriver.Value("Test Name"); ProjectSuite.Variables.TestDescription = DDT.CurrentDriver.Value("Description"); ProjectSuite.Variables.Username = DDT.CurrentDriver.Value("Username"); //Log.Message(ProjectSuite.Variables.Username) ProjectSuite.Variables.Password = DDT.CurrentDriver.Value("Password"); //Log.Message(ProjectSuite.Variables.Password) DDT.CurrentDriver.Next(); } // Close the driver DDT.CloseDriver(DDT.CurrentDriver.Name); }
function excelSmokeTest() { //check Cust_Variables to see what browser and env we're testing, open that browser CheckBrowser(ProjectSuite.Variables.URL); var RecordIdx; for(RecordIdx = 1; RecordIdx <= 4; RecordIdx++) { DataSheet('E-T-E') Log.AppendFolder(ProjectSuite.Variables.TestName, ProjectSuite.Variables.TestDescription) //input username/pw to login login(ProjectSuite.Variables.Username,ProjectSuite.Variables.Password); MAXe_logout(); Log.PopLogFolder(); } }
Related Content
Recent Discussions
- 17 hours agojstaehlin
- 2 days agoAivanitskiy