I need help with writing a logic to validate a dynamic text, below tag is having text which would be changing constantly( to 6 unique words), i need to validate if those 6 unique words are same as expected text. is there a way to validate that.
Note – words are created in incremental way eg – a, ap, app, appl, apple
Advertisement
Answer
public static List<String> getDynamicText(WebDriver driver, By by, int intervalInMiliseconds, int iteration) throws InterruptedException { List<String> collectedTexts = new ArrayList<String>(); for (int i = 1; i <= iteration; i++) { collectedTexts.add(driver.findElement(by).getText()); Thread.sleep(intervalInMiliseconds); } return collectedTexts; }
combine with Compare two ArrayList of String for values inside it in Java Selenium