I have to fetch two labels \'Text 1\', \'Text 2\' which belongs to same class =\'xyz\', which are located in two div\'s.Structure as shown below.
You find elements by className and then use getText() to get the text:
getText()
List elements = driver.findElements(By.className("xyz")); for(WebElement element:elements) { System.out.println(element.getText()); }