I'm using java version "1.8.0_191" and selenium 3.141.59.
I'm trying to find out if a page contains the word "error" or "erreur". Also, I want it to be case insensitive.
Finding a text is easy:
List<WebElement> elementList = driver.findElements(By.xpath("//*[contains(text(), 'error')]"));
By I'm having a harder time making it case insensitive. So far I tried this (inspired by this question):
List<WebElement> elementList = driver.findElements(By.xpath("/html/body//text()[contains(translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'error')]"));
But it return the following error:
org.openqa.selenium.WebDriverException: TypeError: Expected an element or WindowProxy, got: [object Text] {}
I also tried this:
List<WebElement> elementList = driver.findElements(By.xpath("//*[contains(transate(text(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'error')]"));
But it doesn't work either (since it's not a legal expression).
So, any idea in how to make this work?