1 回答

TA貢獻1848條經驗 獲得超2個贊
這個錯誤信息...
Traceback (most recent call last):
? File "Inventorytest.py", line 88, in <module>
? ? j.go_to_application()
? File "Inventorytest.py", line 65, in go_to_application
? ? EC.element_to_be_clickable((By.ID, 'FavoriteApp_ITEM'))
? File "/home/naroladev/Mercury_Back-End/mercuryenv/lib/python3.6/site-packages/selenium/webdriver/support/wait.py", line 80, in until
? ? raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:?
...意味著WebDriver變體無法在構建WebDriverWait的時間范圍內找到所需的WebElement 。
WebDriver等待
WebDriverWait構造函數將WebDriver實例作為參數和超時(以秒為單位)。
因此,無論使用哪一個expected_conditions,WebDriverWait失敗都會導致TimeoutException。
這個用例
在這個用例中,行:
EC.element_to_be_clickable((By.ID,?'FavoriteApp_ITEM'))
無法在所需的時間范圍內識別所需的元素,因此您遇到了TimeoutException。
然而,從TimeoutException中很難挖掘出失敗的實際結果。
解決方案
作為了解失敗確切原因的解決方案,您需要刪除 WebDriverWait并將代碼行替換為:
find_element_by_class_name(name)
find_element_by_css_selector(css_selector)
find_element_by_id(id)
find_element_by_link_text(link_text)
find_element_by_name(name)
find_element_by_partial_link_text(partial_link_text)
find_element_by_tag_name(tag_name)
find_element_by_xpath(xpath)
如果需要,您可以在調試時減慢搜索誘導等待的速度time.sleep(secs)
。
添加回答
舉報