嘗試在頁面上自動注冊時,我在 Selenium 中遇到此錯誤,我無法弄清楚如何與此按鈕進行互動。我可以檢查它,找到它的 XPATH,單擊它,但我無法讓 Selenium 去做。到目前為止,我能夠與頁面中的所有其他內容進行互動,除了這個。
button = driver.find_element(by=By.XPATH, value='//*[@id="mobile-title-bar"]/div/button').click() # click save button
這是我正在使用的代碼,我也嘗試過使用 ActionChains 但遇到了同樣的問題。我假設是因為該按鈕位于疊加層中(請參見螢屏截圖),但由于某種原因無法獲取。我在這里想念什么?編輯:我不能分享網站 URL,它是付費墻后面的服務。
帶有 HTML 元素的頁面圖片:

完整的錯誤文本:
Traceback (most recent call last):
File "C:\Users\Ryan\PycharmProjects\Albert_new_user\main.py", line 45, in <module>
button = driver.find_element(by=By.XPATH, value='//*[@id="mobile-title-bar"]/div/button').click() # click save button
File "C:\Users\Ryan\PycharmProjects\Albert_new_user\venv\lib\site-packages\selenium\webdriver\remote\webelement.py", line 89, in click
self._execute(Command.CLICK_ELEMENT)
File "C:\Users\Ryan\PycharmProjects\Albert_new_user\venv\lib\site-packages\selenium\webdriver\remote\webelement.py", line 773, in _execute
return self._parent.execute(command, params)
File "C:\Users\Ryan\PycharmProjects\Albert_new_user\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 430, in execute
self.error_handler.check_response(response)
File "C:\Users\Ryan\PycharmProjects\Albert_new_user\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 247, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
(Session info: chrome=102.0.5005.63)
Stacktrace:
Backtrace:
Ordinal0 [0x008CD953 2414931]
Ordinal0 [0x0085F5E1 1963489]
Ordinal0 [0x0074C580 836992]
Ordinal0 [0x0077A4F3 1025267]
Ordinal0 [0x00770293 983699]
Ordinal0 [0x0079449C 1131676]
Ordinal0 [0x0076FC74 982132]
Ordinal0 [0x007946B4 1132212]
Ordinal0 [0x007A4812 1198098]
Ordinal0 [0x007942B6 1131190]
Ordinal0 [0x0076E860 976992]
Ordinal0 [0x0076F756 980822]
GetHandleVerifier [0x00B3CC62 2510274]
GetHandleVerifier [0x00B2F760 2455744]
GetHandleVerifier [0x0095EABA 551962]
GetHandleVerifier [0x0095D916 547446]
Ordinal0 [0x00865F3B 1990459]
Ordinal0 [0x0086A898 2009240]
Ordinal0 [0x0086A985 2009477]
Ordinal0 [0x00873AD1 2046673]
BaseThreadInitThunk [0x76B2FA29 25]
RtlGetAppContainerNamedObjectPath [0x76F57A7E 286]
RtlGetAppCo
ntainerNamedObjectPath [0x76F57A4E 238]
uj5u.com熱心網友回復:
在評論中來自@furas 的答案
我不確定,但沒有按鈕,它通常定義按下按鈕后發送請求的位置 - 它可以使它變得不可信。或者它可能在檢測到 Selenium 時使用一些 JavaScript 代碼來阻止訪問。您可以嘗試使用 JavaScript 來單擊它。有點像
driver.execute_script("arguments[0].click()", button)
-弗拉斯
uj5u.com熱心網友回復:
使用此 Xpath 單擊 SAVE 按鈕
//button[contains(text(),'SAVE')]
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/488864.html
