I want to build a String
from text that I've grabbed from WebElements
using WebDriver
.
public String getTextFromWebElements() {
String stringOne= null;
List<WebElement> listOfWebElements = driver.findElements(By.cssSelector(".events-stuff-morestuff"));
for (WebElement we : listOfWebElements) {
stringOne= we.getText();
}
return stringOne;
}
I want stringOne
to build a String
containing a concatenated list of all the text from the WebElements
, not the last one in the loop (as it does currently). Then I will split them out in the code which calls this method, so I can do an Assertion
against data from an API
.