Selenium explicit wait accepts EC.visibility_of_element_located xpath element incorrectly

Viewed 210

I am currently running selenium pytest automation and am running into an issue with explicit wait. I have a WebDriverWait function like such:

WebDriverWait(driver, 10).until(EC.visibility_of_element_located((
    By.XPATH, '//div[@class="ant-card ant-card-bordered" and //*[contains(text(), "Access Points")]]')))

where this specific xpath element does not exist on the page.

Image of page where xpath element does not exist

As such I expect a failed test case. The bizzare thing is that it does work as expected using a docker image and successfully produces a timeout exception, but when run on local web browser it passes through the explicit wait without any timeout exception. I believe there is something weird with the xpath element, because when I edit the text() attribute to a string that does not exist on the page it properly fails. Note that when searching for xpath element with chrome inspect tools the element is not found as seen in the image above

1 Answers

As I see in the attached image: the selected div does not contain the text "Access Points". Let's remove it from the XPath or try to find another div that actually contains such text.

Related