Ishita Shah
Ishita Shah

Reputation: 4035

How to verify presence of multiple text in Selenium

I want to verify one of the metadata present in to div as :

<div ng-if="XXXXXXX" class="XXXXX" >
    <div>March 01 2019, 10:00 am to</div>
    <div>March 28 2019, 6:00 pm</div>
</div>

Need to verify presence of all these Keywords with '01', '28', '10:00 am', '6:00 pm' except Month and Year.

What can be effective way to verify it ?

Upvotes: 1

Views: 982

Answers (1)

Guy
Guy

Reputation: 50809

The parent <div> will hold all the text. Locate it and check if it contains it

WebElement element = driver.findElement(By.className("XXXXX"));
String text = element.getText();
if (text.contains("01") && text.contains("28") && ...) {
    assertTrue(true, "All keywords present");
}

Upvotes: 1

Related Questions