在添加语言之前,我想检查它是否在未来文件的列表中,如果是,删除它,然后从未来文件添加所有

问题描述 投票:0回答:1

我未来的档案:

当管理员从数据表添加多种语言时

  |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);
            }
        }

我做错了什么??

java selenium-webdriver
1个回答
0
投票

我不确定,但可能是吗;

if (name.equalsIgnoreCase(dataName))

代替; if (dataName.equalsIgnoreCase(name))

您正在数据中查找语言名称,不会有其他情况。抱歉,我也有点困惑=)只是想帮忙

© www.soinside.com 2019 - 2024. All rights reserved.