問題描述
我正在嘗試使用 Selenium for Python 和 Chrome 網絡驅動程序來自動下載文件.
I am trying to use Selenium for Python eith the Chrome webdriver to automate the download of a file.
我的程序完美運行到最后一步(點擊下載"按鈕),此時會觸發一個帶有文本的對話框:
My program works perfectly up to the last step (clicking on the 'download' button) at which point a dialog box is triggered with the text:
‘站點 url’出現錯誤:未捕獲的 TypeError:無法讀取 undefined41 的屬性‘getColomnSet’"
這個錯誤是什么意思,最可能的原因是什么?
What does this error mean and what are the most probable causes?
作為參考,這里是我程序的最后幾個命令:
For reference, here are the last few commands of my program:
try:
elem = wait.until(EC.presence_of_element_located((By.ID,'element_1_id')))
finally:
elem1 = driver.find_element_by_id('element_1_id')
elem2 = driver.find_element_by_id('element_2_id')
action = ActionChains(driver).move_to_element(elem1).move_to_element(elem2)
action.perform()
elem2.click()
推薦答案
這個錯誤信息...
An error has occured in 'site url': Uncaught TypeError: Cannot read property 'getColomnSet' of undefined
...暗示您的程序在嘗試下載所需文件時無法讀取屬性getColomnSet.
...implies that your program was unable to read the property getColomnSet while trying to download the desired file.
可能,主要問題是在客戶端呈現 js" rel="nofollow noreferrer">HTML DOM 完全.
Possibly, the main problem is the js
involved to download the document is invoked before the client renders the HTML DOM completely.
相關的HTML、更多的之前的代碼行和錯誤堆棧跟蹤會讓我們對怎么了.
The relevant HTML, a bit more of your previous lines of code and the error stack trace would have given us some more idea about what's going wrong.
- 您可以誘導一些措施等到完成 DOM 樹在討論之后呈現:
- 檢查頁面是否已在 Selenium 中完全加載的通用函數
- 在您的代碼試驗中,我沒有看到您與元素
(By.ID,'element_1_id')
交互,因此您可能可以刪除presence_of_element_located() 的步驟
對于元素(By.ID,'element_1_id')
. - 如果您仍然需要
presence_of_element_located((By.ID,'element_1_id'))
捕獲異常并啟動所需步驟. - 當您在 elem1 和 elem2 上調用
move_to_element()
并繼續調用perform()
時,您需要用 WebDriverWait.webdriver.support.expected_conditions" rel="nofollow noreferrer">expected_conditions 作為element_to_be_clickable(locator)
- In your code trials I don't see you interacting with the element
(By.ID,'element_1_id')
so possibly you can remove the step ofpresence_of_element_located()
for the element(By.ID,'element_1_id')
. - If you still require
presence_of_element_located((By.ID,'element_1_id'))
catch the exception and initiate required steps. - As you invoke
move_to_element()
over elem1 and elem2 and moving ahead invokeperform()
you need to induce WebDriverWait with expected_conditions aselement_to_be_clickable(locator)
- 無法使用畫布讀取 null 的屬性getContext"一個>
- 未捕獲的類型錯誤:無法讀取未定義的屬性getContext"李>
- 未捕獲的錯誤 remote.js
這篇關于“站點 url"中發生錯誤:未捕獲的類型錯誤:無法使用 Selenium 和 Python 讀取未定義的屬性“getColomnSet"的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!