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

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

我在使用 Python Selenium 時(shí)遇到網(wǎng)頁(yè)加載時(shí)間錯(cuò)誤

我在使用 Python Selenium 時(shí)遇到網(wǎng)頁(yè)加載時(shí)間錯(cuò)誤

www說(shuō) 2023-12-11 16:01:28
# Path to the chromedriver programservice = Service('C:\Program Files (x86)\Google\chromedriver.exe')service.start()# Driver opens the remote with robinhood websitedriver = webdriver.Remote(service.service_url)driver.get('https://robinhood.com/crypto/BTC')# We will grab the element id's to log on to Robinhood# driver.find_element_by_id(“ID”).send_keys(“username”)# driver.find_element_by_id (“ID”).send_keys(“password”)# driver.find_element_by_id(“submit”).click()signinButton = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CLASS_NAME, "_3kh8OsNx6QdAbMaoKTi2Yq _1uaripz9PIQ8yApSTs6BKk")))# driver.find_element_by_class_name('_3kh8OsNx6QdAbMaoKTi2Yq _1uaripz9PIQ8yApSTs6BKk')signinButton.click()# Closes the driver after timeoutdriver.quit()我基本上是打開(kāi) chrome webdriver 并訪問(wèn) robinhood 網(wǎng)站,但是我遇到了網(wǎng)頁(yè)加載問(wèn)題。為了修復(fù)它,我嘗試使用 WebDriverWait 停止按鈕單擊,直到加載網(wǎng)頁(yè)。問(wèn)題是按鈕單擊在 10 秒過(guò)去后不會(huì)執(zhí)行,而是拋出此錯(cuò)誤:Traceback (most recent call last):  File "D:/gitRepos/bitmine/runmine.py", line 25, in <module>    signinButton = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CLASS_NAME, "_3kh8OsNx6QdAbMaoKTi2Yq _1uaripz9PIQ8yApSTs6BKk")))  File "D:\Programs Files 2\Python\lib\site-packages\selenium\webdriver\support\wait.py", line 80, in until    raise TimeoutException(message, screen, stacktrace)selenium.common.exceptions.TimeoutException: Message: 
查看完整描述

4 回答

?
阿波羅的戰(zhàn)車

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

此錯(cuò)誤是由于同步問(wèn)題而發(fā)生的。Yu可以通過(guò)使用selenium中的等待來(lái)解決您的問(wèn)題。請(qǐng)參考以下解決方案以避免此類錯(cuò)誤:


WebDriverWait(driver, 30).until(

                EC.element_to_be_clickable((By.XPATH, "//button[@class='_3kh8OsNx6QdAbMaoKTi2Yq _1uaripz9PIQ8yApSTs6BKk']"))).click()

注意:請(qǐng)將以下導(dǎo)入添加到您的解決方案中


from selenium.webdriver.support import expected_conditions as EC

from selenium.webdriver.common.by import By

from selenium.webdriver.support.ui import WebDriverWait

免費(fèi)注冊(cè)按鈕部分:


wait.until(EC.element_to_be_clickable((By.XPATH, "//button[@class='_3kh8OsNx6QdAbMaoKTi2Yq _1uaripz9PIQ8yApSTs6BKk']"))).click()


wait.until(EC.element_to_be_clickable((By.XPATH, "//span[contains(text(),'Sign up for free')]"))).click()



查看完整回答
反對(duì) 回復(fù) 2023-12-11
?
海綿寶寶撒

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

該錯(cuò)誤意味著它在 10 秒內(nèi)沒(méi)有找到可點(diǎn)擊的按鈕,并且超時(shí),拋出 TimeoutException。需要設(shè)置更長(zhǎng)的等待時(shí)間,或者相應(yīng)處理TimeoutException



查看完整回答
反對(duì) 回復(fù) 2023-12-11
?
繁花不似錦

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

該錯(cuò)誤通常是由于無(wú)法在定義的時(shí)間段內(nèi)找到該對(duì)象而引發(fā)的。我寧愿你設(shè)置一個(gè)異常錯(cuò)誤來(lái)捕獲它,并在失敗時(shí)繼續(xù)查找下一個(gè)對(duì)象或元素。


try:

    #Insert your scraping action here

    signinButton.click()

except NoSuchElementException:


查看完整回答
反對(duì) 回復(fù) 2023-12-11
?
Helenr

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

該錯(cuò)誤意味著 selenium 無(wú)法在指定的時(shí)間內(nèi)找到該元素。


也不要在類名中使用空格。只需使用點(diǎn).,否則無(wú)論您增加時(shí)間,硒都將無(wú)法找到它。


from selenium import webdriver


driver = webdriver.Firefox()


driver.get("https://robinhood.com/crypto/BTC")


element = driver.find_element_by_class_name(

    "_3kh8OsNx6QdAbMaoKTi2Yq._1uaripz9PIQ8yApSTs6BKk")


print(element)


查看完整回答
反對(duì) 回復(fù) 2023-12-11
  • 4 回答
  • 0 關(guān)注
  • 179 瀏覽

添加回答

舉報(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)