背景
我在嘗試單擊按鈕時遇到此錯誤。然而,網頁會顯示我無法按下這個提交按鈕,然后它會給我這個錯誤并停止運行程式。有誰知道如何解決這個錯誤。我目前正在使用 CSS 選擇器來查找按鈕。如果我改用另一種方法(例如 XPATH 方法),會有什么不同嗎?此外,我已 100% 驗證我已鍵入正確的元素,同時將WebDriverWait(EC.element_to_be_clickable(slot_submit_button), 4). 本人只學python和selenium,對JavaScript了解不多,請簡單解釋一下,讓我理解這個問題。您的幫助將不勝感激!!
Traceback (most recent call last):
File "C:\Users\Jonathan\PycharmProjects\BBDCBOT\BBDC1.py", line 88, in <module>
slot_submit_button.click()
File "C:\Users\Jonathan\venvs\automation\lib\site-packages\selenium\webdriver\remote\webelement.py", line 80, in click
self._execute(Command.CLICK_ELEMENT)
File "C:\Users\Jonathan\venvs\automation\lib\site-packages\selenium\webdriver\remote\webelement.py", line 693, in _execute
return self._parent.execute(command, params)
File "C:\Users\Jonathan\venvs\automation\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 418, in execute
self.error_handler.check_response(response)
File "C:\Users\Jonathan\venvs\automation\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 243, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <input type="button" name="" value="Submit" class="btn" onclick="postBooking(this.form, 'b-TPDSBookingConfirm.asp?limit=TPDS', '', 'Please select a slot to
book.')" onm ouseover="blueBtnOver(this)" onm ouseout="blueBtnOut(this)"> is not clickable at point (118, 330). Other element would receive the click: <td class="bluetxt">...</td>
(Session info: chrome=96.0.4664.45)
Stacktrace:
Backtrace:
Ordinal0 [0x00743AB3 2505395]
Ordinal0 [0x006DAE41 2076225]
Ordinal0 [0x005E2498 1057944]
Ordinal0 [0x00612C09 1256457]
Ordinal0 [0x00610F48 1249096]
Ordinal0 [0x0060ED0D 1240333]
Ordinal0 [0x0060DB68 1235816]
Ordinal0 [0x00603857 1194071]
Ordinal0 [0x006259F3 1333747]
Ordinal0 [0x00603676 1193590]
Ordinal0 [0x00625ADA 1333978]
Ordinal0 [0x00635168 1397096]
Ordinal0 [0x006258BB 1333435]
Ordinal0 [0x006023E4 1188836]
Ordinal0 [0x0060323F 1192511]
GetHandleVerifier [0x008CCB36 1554566]
GetHandleVerifier [0x00974A0C 2242396]
GetHandleVerifier [0x007D0E0B 523099]
GetHandleVerifier [0x007CFEB0 519168]
Ordinal0 [0x006E02FD 2097917]
Ordinal0 [0x006E4388 2114440]
Ordinal0 [0x006E44C2 2114754]
Ordinal0 [0x006EE041 2154561]
BaseThreadInitThunk [0x76A7FA29 25]
RtlGetAppContainerNamedObjectPath [0x77097A9E 286]
RtlGetAppContainerNamedObjectPath [0x77097A6E 238]
更新:這是元素的 XPATH: slot_submit_button = browser.find_element(By.XPATH, '/html/body/table/tbody/tr/td[2]/form/table[2]/tbody/tr[1]/td[1]/input[2]')
這是元素的 CSS 選擇器: slot_submit_button = browser.find_element(By.CSS_SELECTOR, 'input[value="Submit"]')
uj5u.com熱心網友回復:
此錯誤意味著該元素存在于 DOM 中,但與其他某個元素重疊。
在你的情況下,
<input type="button" name="" value="Submit" class="btn" onclick="postBooking(this.form, 'b-TPDSBookingConfirm.asp?limit=TPDS', '', 'Please select a slot to
book.')" onm ouseover="blueBtnOver(this)" onm ouseout="blueBtnOut(this)">
被重疊
<td class="bluetxt">...</td>
uj5u.com熱心網友回復:
錯誤意味著這種情況是網頁元素重疊。在這里,點擊是根據您的代碼執行的,但是在該位置存在一些其他元素進行了點擊。
使用 javascript 決議:-
button = find_element(By.XPATH, '<Valid Xpath>')
driver.execute_script("arguments[0].click();", button)
方法是使用 javascript 代碼單擊它,該代碼對找到的第一個與 XPath 匹配的引數執行單擊操作。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/367180.html
