这是我的代码:
Excel 实用程序:
public static Object [][] getTestData(String sheetName)
{
try
{
FileInputStream ip = new FileInputStream(TESTDATA_SHEET_PATH);
try
{
book = WorkbookFactory.create(ip);
}
catch (InvalidFormatException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
sheet = book.getSheet(sheetName);
Object data[][] = new Object[sheet.getLastRowNum()][sheet.getRow(0).getLastCellNum()];
for (int i = 0; i < sheet.getLastRowNum(); i++)
{
for (int k = 0; k < sheet.getRow(0).getLastCellNum(); k++)
{
// if(data[i][k]!=null)
data[i][k] = sheet.getRow(i+1).getCell(k).toString();
}
}
return data;
}
catch (FileNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("Not able to fetch the values from the Excel");
}
return null;
}
我需要从下拉列表中选择多个值的页面方法:
public void pipeline(String fieldvalue,String savepipe)
{
elementutils.waitforElementPresent(DealsLink);
elementutils.doclick(DealsLink);
elementutils.waitforclickingElement(pipeline);
elementutils.doclick(pipeline);
elementutils.waitforElementPresent(Selectfieldsdropdownclick);
elementutils.doclick(Selectfieldsdropdownclick);
elementutils.selectvaluefromdropdown(selectfieldsvalueselection, fieldvalue);
}
测试页方法:
@DataProvider
public Object[][] dealpipeline()
{
Object data[][] = ExcelUtil.getTestData(AppConstants.Deal_Pipeline_Sheet_Name);
return data;
}
@Test(priority=10,dataProvider="dealpipeline")
public void getdealspipelineinfo(String selectfields,String savepipelineas)
{
dealspage.pipeline(selectfields, savepipelineas);
}
页面:有一个下拉列表,我们可以从下拉列表中一次选择两个值
![在此处输入图像描述][1]
屏幕截图显示了下拉列表
[1]: https://i.stack.imgur.com/VuP03.png
带有值选择字段 Stage、Commission 的 Excel 文件。
当我运行此测试时,它不会选择 Excel 中的值,也不会显示任何错误。有人可以让我知道需要做什么吗?