Verify list elements by Selenium WebDriver

前端 未结 2 534
北荒
北荒 2020-12-18 14:58
WebElement select = myD.findElement(By.xpath(\"//*[@id=\'custfoodtable\']/tbody/tr[2]/td/div/select\"));
List allOptions = select.findElements(By.t         


        
2条回答
  •  离开以前
    2020-12-18 15:50

    You can do it like this:

    String[] act = new String[allOptions.length];
    int i = 0;
    for (WebElement option : allOptions) {
        act[i++] = option.getValue();
    }
    
    List expected = Arrays.asList(exp);
    List actual = Arrays.asList(act);
    
    Assert.assertNotNull(expected);
    Assert.assertNotNull(actual);
    Assert.assertTrue(expected.containsAll(actual));
    Assert.assertTrue(expected.size() == actual.size());
    

提交回复
热议问题