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

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Selenium find_element 嘗試除了“WebElement”對象不可調用

Selenium find_element 嘗試除了“WebElement”對象不可調用

ibeautiful 2021-11-02 09:47:13
我在網(wǎng)頁上搜索 ID lieferschein。如果我在沒有 try 和 except 塊的情況下進行搜索,我可能會找到 ID,tab_check = driver.find_element_by_id('lieferschein')如果不try:    tab_check = driver.find_element_by_id('lieferschein')    # breakexcept:    pass我收到這樣的錯誤:Traceback (most recent call last):  File "<input>", line 3, in <module>TypeError: 'WebElement' object is not callableDuring handling of the above exception, another exception occurred:Traceback (most recent call last):  File "<input>", line 6, in <module>TypeError: 'WebElement' object is not callable全碼:from selenium import webdriverimport picklefrom selenium.common.exceptions import NoSuchElementExceptionabURL = 'https://farm01.afterbuy.de/afterbuy/auktionsliste.aspx?AWebayname=&AWFilter=37&AWSuchwort=&AWRENummer=&AWFilter2=0&awmaxart=500&maxgesamt=1000&AWEmail=&AWDatumVon=&AWDatumBis=&AWBezug=EndeDerAuktion&AWPLZ=&AWBetrag=&AWBetragBezug=1&AWStammID=&AWLaenderkennung=&AWLaenderkennungBezug=rechnung&AWLabelDynSearchField1=ShippingAddress&AWDynSearchField1=&AWLabelDynSearchField2=AlterItemNumber1&AWDynSearchField2=&AWDynamicSorting=0&AWLabelDynSearchField3=AlterItemNumber&AWDynSearchField3=&searchUserTag1=0&searchUserTag2=0&searchUserTag3=0&searchUserTag4=0&killordersession=0&art=SetAuswahl'download_dir = "C:\\Users\\Oli\\Documents"options = webdriver.ChromeOptions()driver = webdriver.Chrome()driver.get(abURL)cookies = pickle.load(open("cookies.pkl", "rb"))for cookie in cookies:    driver.add_cookie(cookie)for tab in driver.window_handles:    driver.switch_to.window(tab)    try:        tab_check = driver.find_element_by_id('lieferschein')        # break    except NoSuchElementException:        pass
查看完整描述

1 回答

?
守候你守候我

TA貢獻1802條經驗 獲得超10個贊

由于您正在使用except: pass,這會捕獲所有可能的異常,一些發(fā)生的異常暫時被忽略,但稍后會默默地制造一個更難調試的問題。


NoSuchElementException異常由 引發(fā).find_element_by_id('anyID'),因此最好為 明確提及它except。


try:

    tab_check = driver.find_element_by_id('lieferschein')

    # break

except NoSuchElementException:

    print('No element of that id present!')


查看完整回答
反對 回復 2021-11-02
  • 1 回答
  • 0 關注
  • 253 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號