我有一個元素的屬性「詠歎調」,當數據在搜索和完成時,從真變爲假。如何使用selenium Expected Conditions和Explicit Waits來等待20秒的默認時間,如果達到20秒並且屬性沒有從true更改爲false。拋出異常。我有以下,但它並沒有真正的工作使用硒webdriver等待元素的屬性來改變值
import selenium.webdriver.support.ui as ui
from selenium.webdriver.support import expected_conditions as EC
<div id="xxx" role="combobox" aria-busy="false" /div>
class Ele:
def __init__(self, driver, locator)
self.wait = ui.WebDriverWait(driver, timeout=20)
def waitEle(self):
try:
e = self.driver.find_element_by_xpath('//div[@id='xxxx']')
self.wait.until(EC.element_selection_state_to_be((e.get_attribute('aria-busy'), 'true')))
expect:
raise Exception('wait timeout')