Forum Discussion

EkremMese1's avatar
EkremMese1
Contributor
6 months ago

Item cannot be found in the collection corresponding to the requested name or ordinal

I created a test with scripting. Everything was working fine. 

Then I decided to use a Data Driven Testing approach with an excel file. 

My code started to give me the error in the caption. 

Here is my code: 

function search_with_loop(){
  DDT.ExcelDriver("Z:\\MeseE\\TestData_EIDSS_V7.xlsx", "Person_Search")
  DDT.CurrentDriver.DriveMethod("SearchPerson.search_for_existing_record")
}


/*

function search_for_existing_record(){
  
  //store the logs in related folders
  Log.AppendFolder(DDT.CurrentDriver.Value("Last_Name"));
  Log.Message(DDT.CurrentDriver.Value("Last_Name") + " here");
  //Log.AppendFolder("Solomatyn");  
  
  navigate_person_search_form();
  browser = Aliases.browser;
  browser.BrowserWindow.Maximize();
  let form = browser.pagePersonEidss.formPersonsearchform;
  
  let textbox = form.textboxLastName;
   
  //wait textbox to be enabled
  //textbox.WaitTypeName(textbox,2000);
  
  Log.Message(textbox.Exists);
  textbox.WaitProperty("Enabled", true, 2000);
  
  
  textbox.Click();
  
  textbox.SetText(DDT.CurrentDriver.Value("Last_Name"));
 
  //textbox.SetText("Solomatyn");
  
  form.buttonSearchbutton.ClickButton();
  aqObject.CheckProperty(form.lastNameLabelInGrid, "contentText", cmpEqual, DDT.CurrentDriver.Value("Last_Name"));
  
  //aqObject.CheckProperty(form.lastNameLabelInGrid, "contentText", cmpEqual, "Solomatyn");
  Log.PopLogFolder();
  
  browser.Close();


}
*/


function search_for_existing_record()
{
  navigate_person_search_form();
  Log.AppendFolder(DDT.CurrentDriver.Value("Person ID"));
  

  let page = browser.pagePersonEidss;
  page.Wait();
  let textbox = page.formPersonsearchform;

  let textbox3 = textbox.textboxPersonId;

  textbox3.WaitProperty("Enabled", true, 2000);
  textbox3.setText(DDT.CurrentDriver.Value("Person ID"));
  
  textbox.buttonSearchbutton.ClickButton();

  aqObject.CheckProperty(textbox.hyperLinkInGrid, "contentText" , cmpEqual, DDT.CurrentDriver.Value("Person ID"))
  
  
  
  Log.PopLogFolder(); 
  browser.Close();
}

Does anyone has an idea about it?


  • Hello again, 

    I just find out that the issue is cause by not closing the driver in the methods that I called in my code. 

    DDT.CloseDriver(DDT.CurrentDriver.Name);

    This line solved issue for me.