我未来的档案:
当管理员从数据表添加多种语言时
|Name|
|German|
|Turkish|
|Spain|
我的步骤:
public void adminAddMultipleLanguageFromDatatable
(io.cucumber.datatable.DataTable dataTable) throws InterruptedException
{
List<WebElement> Languages = driver.findElements(By.xpath("//table/tbody/tr/td[2]"));
List<Map<String, String>> data = dataTable.asMaps();
for (Map<String, String> datas : data) {
for (int i = 0; i < Languages.size(); i++) {
String dataName = datas.get("Name");
String name = Languages.get(i).getText();
if (dataName.equalsIgnoreCase(name)) {
WebElement checkBox = driver.findElement(By.xpath("//table/tbody/tr[" + (i + 1) + "]/td[1]"));
click(checkBox);
click(addLanguagePage.languageDelBtn);
WebElement mes = driver.findElement(By.xpath("//div[@class='message warning fadable']"));
String m = "Successfully Deleted\n" +
"Close";
String m1 = mes.getText();
Assert.assertEquals(m, m1);
}
click(addLanguagePage.languageAddBtn);
sendText(datas.get("Name"), addLanguagePage.languageNameOption);
click(addLanguagePage.languageSaveBtn);
WebElement m2 = driver.findElement(By.xpath("//div[@class='message success fadable']"));
String mm2 = m2.getText();
String expecct = "Successfully Saved\n" +
"Close";
Assert.assertEquals(expecct, mm2);
}
}
我做错了什么??
我不确定,但可能是吗;
if (name.equalsIgnoreCase(dataName))
代替; if (dataName.equalsIgnoreCase(name))
您正在数据中查找语言名称,不会有其他情况。抱歉,我也有点困惑=)只是想帮忙