1
運行Selenium腳本時出現不一致的TimeoutException。如果我使用PyCharm調試器逐句通過腳本,在每一行中暫停腳本,腳本將成功運行(斷言通道,不會有TimeoutException)。與Python和Selenium不一致selenium.common.exceptions.TimeoutException
但是,當我正常運行腳本時,每次在最後一次wait.until()時都會收到TimeoutException。我已經閱讀了關於EC.presence_of_element_located的文檔,並且我相信我正確地使用了它。爲什麼我得到這個異常?下面的代碼:
def test_if_special_diet_types_are_correct(self):
wait = WebDriverWait(self.driver, 10)
utils = Utils(self.driver, wait, self)
utils.login()
tab = self.driver.find_element_by_id("clients-tab")
tab.click()
list_item = wait.until(EC.presence_of_element_located((By.ID, '66')))
list_item.click()
edit_button = wait.until(EC.presence_of_element_located((By.ID, 'edit-client-button')))
edit_button.click()
element = wait.until(EC.presence_of_element_located((By.ID, 'client-input-first-name')))
self.assertEqual('John', element.get_attribute('value'))
而這裏的錯誤:
Error
Traceback (most recent call last):
File "/Users/jcleveland/projects/zippymeals/browser_tests/account.py", line 54, in test_if_special_diet_types_are_correct
EC.presence_of_element_located((By.ID, 'client-input-first-name')))
File "/Users/jcleveland/projects/zippymeals/env/lib/python3.4/site-packages/selenium/webdriver/support/wait.py", line 80, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: