第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

程序在調(diào)試模式下運(yùn)行正常,但正常運(yùn)行卻出現(xiàn)錯(cuò)誤

程序在調(diào)試模式下運(yùn)行正常,但正常運(yùn)行卻出現(xiàn)錯(cuò)誤

明月笑刀無(wú)情 2023-11-09 21:42:29
這是我當(dāng)前的代碼,但是每當(dāng)我運(yùn)行它時(shí),最后一行都會(huì)出現(xiàn)錯(cuò)誤stale element reference: element is not attached to the page documentfrom selenium import webdriverurl = "https://otctransparency.finra.org/otctransparency/OtcDownload"driver.get(url)driver.maximize_window()driver.implicitly_wait(5)agree = driver.find_elements_by_xpath("//button[@class='btn btn-warning']")[0]agree.click()nonats = driver.find_element_by_link_text('OTC (Non-ATS) Download')nonats.click()driver.find_element_by_xpath("//img[@src='./assets/icon_download.png']").click()driver.switch_to.window(driver.window_handles[0])driver.find_element_by_xpath("(//div[@class='checkbox-inline'])[2]").click()driver.find_element_by_xpath("(//div[@class='checkbox-inline'])[1]").click()driver.implicitly_wait(5)button = driver.find_element_by_xpath("//img[@src='./assets/icon_download.png']")print(button.is_displayed())button.click()當(dāng)我在調(diào)試模式下逐行運(yùn)行代碼時(shí),一切正常,沒(méi)有任何錯(cuò)誤。任何幫助都會(huì)很棒。編輯:這是我的堆棧跟蹤Traceback (most recent call last): File "C:\Users\derpe\Desktop\python projects personal\testing finra\untitled1.py", line 31, in <module>    button.click()  File "C:\Users\derpe\anaconda3\lib\site-packages\selenium\webdriver\remote\webelement.py", line 80, in click    self._execute(Command.CLICK_ELEMENT)  File "C:\Users\derpe\anaconda3\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute    return self._parent.execute(command, params)  File "C:\Users\derpe\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute    self.error_handler.check_response(response)  File "C:\Users\derpe\anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response    raise exception_class(message, screen, stacktrace)StaleElementReferenceException: stale element reference: element is not attached to the page document  (Session info: chrome=86.0.4240.75)
查看完整描述

1 回答

?
不負(fù)相思意

TA貢獻(xiàn)1777條經(jīng)驗(yàn) 獲得超10個(gè)贊

當(dāng)您搜索下載鏈接時(shí),單擊復(fù)選框會(huì)觸發(fā)頁(yè)面刷新。


調(diào)用sleep以允許刷新完成。


driver.implicitly_wait(5)

import time   # add this 

time.sleep(1)   # add this

button = driver.find_element_by_xpath("//img[@src='./assets/icon_download.png']")

print(button.is_displayed())

button.click()

我嘗試了其他硒等待,但它們對(duì)我不起作用??赡苁且?yàn)樵厮阉髟谒⑿麻_(kāi)始之前成功但仍然點(diǎn)擊較晚。


查看完整回答
反對(duì) 回復(fù) 2023-11-09
  • 1 回答
  • 0 關(guān)注
  • 141 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)