0

我在 Excel 中为 DataDriven 框架创建数据。如果有下拉菜单,我遇到了如何使用该数据的问题。

示例-对于旅游站点,到达列表中有引用的下拉列表

如果我在 excel 中保留所有引用名称,如何在框架中使用它。

4

1 回答 1

0

由于您使用的是 Java,因此您可以在此处使用TestNG单元测试框架。特别是@dataprovider示例。对于从 excel 获取数据的代码,您可以使用JExcel api。.

下面的代码将为excel文件中的每个城市一一运行相同的测试用例,并从下拉列表中进行选择。请参阅下面的代码以获取更多参考:

@Test(dataProvider = "DP1")
public void selectCityFromDropDown(String city) throws Exception {
    // Selenium webdriver code for selecting city from  drop down.
}

@DataProvider(name = "DP1")
public Object[][] createData1() throws Exception {
    // code to open excel file, fetch data from excel file and generate two dimentional array of String/Object class so that it can be returned back to test case
}
于 2014-05-13T14:06:44.277 回答