I'm new to Selenium. I like to verify if a specific class contains a text snippet in JavaScript.
I have following HTML:
<div class="product-small">
<div class="data">
<p>This is some Text</p>
</div>
</div>
<div class="product-small">
<div class="data">
<p>This is some Text</p>
</div>
</div>
...
The above class are available multiple times on the page, so i have to iterate the "product-small" class to check if all 12 classes contains the text "some". If one of the 12 elements with that "product-small" class does not contain the text "some", the test will fail.
I thought something like this:
const cars = driver.findElements(By.className('product-small'));
cars.forEach(function (element) {
// Check if element contains "some" inside class "data"
// If element does not contain "some", test will fail
});
Thank you :)