0

Hi I have an ArrayList and a WebElement list with same data. I need to know how I can compare the values in my ArrayList with values in my List WebElements:

ArrayList<String> shift = new ArrayList<String>();
shift.add("A1");
shift.add("A2");
shift.add("A3");
shift.add("B1");
shift.add("B2");
shift.add("B3");

System.out.println("List of all elements: " + shift);

List<WebElement> elements = driver.findElements(By
                           .className("shift-names"));
for (WebElement element : elements) {
    System.out.println(element.getText());
}
Bashir
  • 2,057
  • 5
  • 19
  • 44
Ramya Dipu
  • 61
  • 11

1 Answers1

0

If lists should be fully same, then you can do next:

for (int i = 0; i <= elements.count(); i++) {
    String textActual = elements[i].getText();
    String textExpected = shift.get(i);
    Assert.areEquals(textActual, textExpected);
}

Maybe a problem with syntax.

Ukrainis
  • 534
  • 2
  • 16