The implementation of textToBePresentInElement is as follows:
public static ExpectedCondition<Boolean> textToBePresentInElement(
final WebElement element, final String text) {
return new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
try {
String elementText = element.getText();
return elementText.contains(text);
} catch (StaleElementReferenceException e) {
return null;
}
}
@Override
public String toString() {
return String.format("text ('%s') to be present in element %s", text, element);
}
};
}
If you create a new implementation like this:
public static ExpectedCondition<Boolean> loweredTextToBePresentInElement(
final WebElement element, final String text) {
return new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
try {
String elementText = element.getText().toLowerCase();
return elementText.contains(text.toLowerCase());
} catch (StaleElementReferenceException e) {
return null;
}
}
@Override
public String toString() {
return String.format("text ('%s') to be present in element %s", text, element);
}
};
}
And use the new implementation it will ignore the case of the text sent in and work as desired.