I'm writing some tests for our web application. When I use this XPath inside the Firefox XPath-Checker plugin it just works fine:
//div[contains(@class, "my-class") and @data-custom-attr="id")]
But If use this in selenium code like so:
(new WebDriverWait(driver, MAX_TIMEOUT_FOR_ELEMENT_LOADING_IN_SECONDS)).until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[contains(@class, \"my-class\") and @data-custom-attr=\"id\")]"));
a timeout exception is throwen.
Why does the xpath query works directly in the browser but not in the selenium test? Is there documentation on what I have to consider?
As side note: if I use the exact path /html/body/div/... etc. it does work. And a css selector pendant to my example above doesn't work either.
MAX_TIMEOUT_FOR_ELEMENT_LOADING_IN_SECONDS? Is it enough time for the element to become present? - Dingredient