In my utils have created the below code
public void selectvaluefromdropdown(By locator,String value)
{
List<WebElement> options = driver.findElements(locator);
for(int i=0;i<options.size();i++)
{
String option = options.get(i).getText();
System.out.println("Display all the options:"+ option);
if(option.equalsIgnoreCase(value))
{
options.get(i).click();
break;
}
}
}
}
//In the Page class have created the below code by calling the element utils class methods.cate is the one which need to select the value from the drop down
this is the locator for clicking the category drop down - By category = By.xpath("//div[@name='category']");
public void enterallfielddetails(String fname,String lname,String midname,String mail,String cate)
{
elementutils.waitforElementPresent(firstname);
elementutils.doSendKeys(firstname, fname);
elementutils.waitforElementPresent(lastname);
elementutils.doSendKeys(lastname, lname);
elementutils.waitforElementPresent(middlename);
elementutils.doSendKeys(middlename, midname);
elementutils.waitforElementPresent(email);
elementutils.doSendKeys(email, mail);
elementutils.selectvaluefromdropdown(category, cate);
In the Test Class has used the Data Provider to read the value from the Excel and called the DataProvider in the method :
Now when I run this getting a Data Provider mismatch is bz of the Category drop-down so how do I handle this
@DataProvider
public Object[][] getNewCompanydetails()
{
Object[][] data = ExcelUtil.getTestData(AppConstants.New_Company_Sheet_Name);
return data;
}
@Test(priority=3,dataProvider="getNewCompanydetails")
public void getCompanyDetails(String firstname,String lastname,String middlenames,String emailaddress,String category)
{
contactspage.enterallfielddetails(firstname, lastname, middlenames,emailaddress,category);
}
}