国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

解決selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted

這篇具有很好參考價值的文章主要介紹了解決selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

用selenium爬數(shù)據(jù)的時候,明明每一步點擊都加了WebDriverWait,但還是爬一會兒就顯示如下錯誤:

selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <tr class="even" onclick="onclick_shipinsp(this,'insp')">...</tr> is not clickable at point (509, 404). Other element would receive the click: <div class="blockUI blockOverlay ui-widget-overlay" style="z-index: 1000; position: fixed; opacity: 0;"></div>
  (Session info: chrome=110.0.5481.178)

這里一定要注意后面的這句

“ Other element would receive the click: <div class="blockUI blockOverlay ui-widget-overlay" style="z-index: 1000; position: fixed; opacity: 0;"></div>
  (Session info: chrome=110.0.5481.178)

也就是說我們想點擊的按鈕沒點成,而是被這個覆蓋了。
查資料得知:

blockUI 是一個 JavaScript 庫,用于創(chuàng)建可定制的頁面遮罩和加載指示器。它提供了一個簡單的方式來阻止用戶在頁面加載或執(zhí)行某些任務時進行交互,并顯示一個加載指示器,以提示用戶頁面正在處理。

解決嘗試一:
加一個異常處理塊,這里try塊中是之前報錯的地方,一旦出現(xiàn)異常則對之前bug說明里出現(xiàn)的元素進行隱藏,然后再次嘗試點擊。

try:
    driver.find_element(By.XPATH,xpath_pattern).click()
except:
    wait = WebDriverWait(driver, 100)
    element = wait.until(EC.visibility_of_element_located((By.CLASS_NAME, 'blockUI blockOverlay ui-widget-overlay')))
    driver.execute_script("arguments[0].style.display = 'none';", element)
    try:
    driver.find_element(By.XPATH,xpath_pattern).click()

嘗試之后:比之前多撐了一會兒但在except塊中還是會報錯找不到元素。

解決嘗試二:

        for i in range(3):
            try:
                click_button(driver, index_xpath)
                break
            except:
                # 如果點擊元素失敗,檢查元素是否存在且可見
                block_overlay = driver.execute_script(
                    "return document.querySelector('.blockUI.blockOverlay.ui-widget-overlay')")
                if block_overlay and block_overlay.is_displayed():
                    # 如果元素存在且可見,隱藏元素
                    driver.execute_script(
                        "document.querySelector('.blockUI.blockOverlay.ui-widget-overlay').style.display='none';")
                try:
                    click_button(driver, index_xpath)
                    break
                except:
                    # 如果還是失敗,等待一段時間再嘗試
                    time.sleep(10)

目前這種解決方法暫時可行。學習爬蟲不久,有更好方法的朋友歡迎指教。文章來源地址http://www.zghlxwxcb.cn/news/detail-511590.html

到了這里,關于解決selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網!

本文來自互聯(lián)網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。如若轉載,請注明出處: 如若內容造成侵權/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經查實,立即刪除!

領支付寶紅包贊助服務器費用

相關文章

  • selenium報錯解決:selenium.common.exceptions.WebDriverException: Message(已解決)

    selenium報錯解決:selenium.common.exceptions.WebDriverException: Message(已解決)

    今天使用selenium遇到報錯: selenium.common.exceptions.WebDriverException: Message: Service ./windows/chromedriver.exe unexpectedly exited. Status code was: 1 報錯截圖: ? 檢查了代碼沒有發(fā)現(xiàn)問題,根據(jù)報錯初步判斷問題是出在chromedriver的路徑上面,對比之前的代碼 乍一看不能發(fā)現(xiàn)問題,仔細對比發(fā)現(xiàn)是

    2024年02月11日
    瀏覽(31)
  • 解決:selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘ execu

    解決:selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘ execu

    運行爬蟲代碼出現(xiàn)上面的bug bug詳細信息如下 ?解決方法 如下 1.先打開chrome 輸入 “chrome://version/”來查看chrome版本 如圖我的是96 ? 2.然后訪問此網站??http://chromedriver.storage.googleapis.com/index.html?? 然后選擇合適版本的driver? ?我這邊是windows版本的系統(tǒng)所以下載? win32版本的壓縮

    2024年02月16日
    瀏覽(24)
  • 已解決selenium.common.exceptions.TimeoutException: Message: script timeout

    已解決selenium.common.exceptions.TimeoutException: Message: script timeout

    已解決(selenium模塊操作瀏覽器報錯)selenium.common.exceptions.TimeoutException: Message: script timeout 粉絲群里面的一個粉絲用selenium模塊操作瀏覽器爬取網頁數(shù)據(jù),但是發(fā)生了報錯(跑來找我求助,然后順利幫助他解決了,順便記錄一下希望可以幫助到更多遇到這個bug不會解決的小伙伴

    2024年01月15日
    瀏覽(32)
  • 【報錯解決】selenium.common.exceptions.WebDriverException: Message: invalid argument

    【報錯解決】selenium.common.exceptions.WebDriverException: Message: invalid argument

    在做Web自動化測試的實驗報告的時候遇到一個報錯。 運行代碼: 報錯: selenium.common.exceptions.WebDriverException: Message: invalid argument (Session info: chrome=113.0.5672.92) (Driver info: chromedriver=113.0.5672.63 (0e1a4471d5ae5bf128b1bd8f4d627c8cbd55f70c-refs/branch-heads/5672@{#912}),platform=Windows NT 10.0.19044 x86_64) 這

    2024年02月05日
    瀏覽(32)
  • 已解決selenium.common.exceptions.WebDriverException: Message: invalid session id

    已解決selenium.common.exceptions.WebDriverException: Message: invalid session id

    已解決selenium循環(huán)翻頁拋出selenium.common.exceptions.WebDriverException: Message: invalid session id的正確解決方法,親測有效?。。?粉絲群里面的一個小伙伴遇到問題跑來私信我,想用selenium循環(huán)翻頁,但是發(fā)生了報錯(當時他心里瞬間涼了一大截,跑來找我求助,然后順利幫助他解決了,

    2023年04月08日
    瀏覽(27)
  • 解決selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable報錯

    這個錯誤是由Selenium WebDriver引起的,它表示一個元素無法與之交互。 這通常意味著Selenium無法模擬用戶與該元素交互的方式,可能是由于以下原因之一: 元素被隱藏了,無法與之交互。 元素被覆蓋了,無法與之交互。 元素不可見,無法與之交互。 頁面還沒有完全加載,元素

    2024年02月14日
    瀏覽(26)
  • 一文解決:selenium.common.exceptions.SessionNotCreatedException: Message: session not created

    一文解決:selenium.common.exceptions.SessionNotCreatedException: Message: session not created

    你遇到的錯誤消息表明您正在使用的ChromeDriver的版本與您計算機上安裝的Google Chrome版本不兼容。ChromeDriver是一個獨立的可執(zhí)行文件,WebDriver使用它來控制Chrome瀏覽器。要解決這個問題,您有幾個可能的解決方案,具體介紹如下所示。 1.修改ChromeDriver的版本 此方法需要首先查

    2024年02月08日
    瀏覽(28)
  • selenium.common.exceptions.SessionNotCreatedException: Message: session not created 解決辦法

    selenium.common.exceptions.SessionNotCreatedException: Message: session not created 解決辦法

    一、問題原因 報這個錯是因為 當前瀏覽器的版本與 chromedriver.exe的版本不一致了。這個時候你需要先知道自己當前瀏覽器的版本 ,然后再去下載一個 chromedriver.exe的對應版就好了 二、解決辦法 1、查看瀏覽器版本 幫助-關于Google Chrome https://registry.npmmirror.com/binary.html?path=chro

    2024年02月11日
    瀏覽(23)
  • selenium.common.exceptions.WebDriverException: Message: chrome not reachable解決方法

    在 python上使用 selenium 。 一開始還算順利,但是隨著反復執(zhí)行,處理量變多了。 如果一直等待,最終會出現(xiàn)無法訪問 chrome 的錯誤。 已經添加了driver.quit()。 引入一個新的函數(shù),檢查是否有 chrome 驅動程序正在運行,并打印提示,如果有,則殺死所有chrome 驅動程序。 相當于在

    2024年02月16日
    瀏覽(19)
  • 【python selenium報錯】selenium.common.exceptions.WebDriverException: Message: <html> 三種解決方案!

    【python selenium報錯】selenium.common.exceptions.WebDriverException: Message: <html> 三種解決方案!

    在運行python代碼時遇到該問題解決方案三種(我是第三種才解決的,總結一句話:是代理ip的問題★★★): 一、重新安裝selenium,可能是缺少某些文件 二、查看chrom的版本,在chrom驅動的官方網站中下載安裝適配的版本(版本接近即可),并將其配置到系統(tǒng)環(huán)境下,具體步驟

    2024年02月11日
    瀏覽(40)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領取紅包,優(yōu)惠每天領

二維碼1

領取紅包

二維碼2

領紅包