I'm trying to select an element in Selenium using Python which looks like this:
<div class="class1 class2" an-attribute="attribute-value"></div>
and use it inside a wait on an expected condition like this:
WebDriverWait(self.driver, timeout).until(
expected_conditions.presence_of_element_located(
(By.XPATH, '//div[@an-attribute="attribute-value"][@class="class1 class2"]')))
This wait always results in a TimeoutException.
I've also tried the alternative XPath syntax:
'//div[@an-attribute="attribute-value" and @class="class1 class2"]'
I am able to get this element using the same XPath value in find_element_by_xpath()
.
If I pause the test and inspect the browser web console, I can see that the div indeed has this attribute and classes. This is true for both Firefox and Chromium.
Is this a bug in Selenium or am I using it incorrectly?