0

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

Dynamic text Html

9
  • Use //span[@class='search-placeholder'] by xpath then .getText(). I'm not sure how it's changing it's values. Commented Feb 21, 2022 at 20:48
  • @Prophet help me understand what do you mean Commented Feb 22, 2022 at 6:58
  • If you know the interval of change, you can simply collect texts after sleeps or waits into list of strings. Commented Feb 22, 2022 at 7:01
  • @ArundeepChohan, //span[@class='search-placeholder'] by xpath then .getText() will get text at that point of time, for example when page is loaded text will be app but that wont be complete word Commented Feb 22, 2022 at 7:01
  • @pburgr , i think I can get the interval time and any suggestion how i can get all 6 unique word and validate with expected text Commented Feb 22, 2022 at 7:04

1 Answer 1

0
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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.