pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    <legend id='e3o4z'><style id='e3o4z'><dir id='e3o4z'><q id='e3o4z'></q></dir></style></legend>
    <tfoot id='e3o4z'></tfoot>

      <bdo id='e3o4z'></bdo><ul id='e3o4z'></ul>

    <small id='e3o4z'></small><noframes id='e3o4z'>

    1. <i id='e3o4z'><tr id='e3o4z'><dt id='e3o4z'><q id='e3o4z'><span id='e3o4z'><b id='e3o4z'><form id='e3o4z'><ins id='e3o4z'></ins><ul id='e3o4z'></ul><sub id='e3o4z'></sub></form><legend id='e3o4z'></legend><bdo id='e3o4z'><pre id='e3o4z'><center id='e3o4z'></center></pre></bdo></b><th id='e3o4z'></th></span></q></dt></tr></i><div class="nfdrt55" id='e3o4z'><tfoot id='e3o4z'></tfoot><dl id='e3o4z'><fieldset id='e3o4z'></fieldset></dl></div>
    2. AttributeError: 'list' 對象沒有使用 Selenium 和

      AttributeError: #39;list#39; object has no attribute #39;click#39; using Selenium and Python(AttributeError: list 對象沒有使用 Selenium 和 Python 的屬性 click)
        <bdo id='ba1UE'></bdo><ul id='ba1UE'></ul>

        <tfoot id='ba1UE'></tfoot>

        <small id='ba1UE'></small><noframes id='ba1UE'>

          <i id='ba1UE'><tr id='ba1UE'><dt id='ba1UE'><q id='ba1UE'><span id='ba1UE'><b id='ba1UE'><form id='ba1UE'><ins id='ba1UE'></ins><ul id='ba1UE'></ul><sub id='ba1UE'></sub></form><legend id='ba1UE'></legend><bdo id='ba1UE'><pre id='ba1UE'><center id='ba1UE'></center></pre></bdo></b><th id='ba1UE'></th></span></q></dt></tr></i><div class="brp5zvx" id='ba1UE'><tfoot id='ba1UE'></tfoot><dl id='ba1UE'><fieldset id='ba1UE'></fieldset></dl></div>
            <tbody id='ba1UE'></tbody>
          <legend id='ba1UE'><style id='ba1UE'><dir id='ba1UE'><q id='ba1UE'></q></dir></style></legend>
                本文介紹了AttributeError: 'list' 對象沒有使用 Selenium 和 Python 的屬性 'click'的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我想在默認設置為季度"的頁面上單擊年度"按鈕.有兩個鏈接基本上被稱為相同,除了一個有 data-ptype="Annual" 所以我嘗試復制 xpath 以單擊按鈕(也嘗試了其他選項,但沒有一個有效).

                I'd like to click the button 'Annual' at a page that is by default set on 'Quarterly'. There are two links that are basically called the same, except that one has data-ptype="Annual" so I tryed to copy the xpath to click the button (also tried other options but none did work).

                但是,我得到 AttributeError: 'list' object has no attribute 'click'.我閱讀了很多類似的帖子,但無法解決我的問題..所以我認為 javascript 事件必須以某種方式被調用/單擊/執行.. idk 我卡住了

                However, I get the AttributeError: 'list' object has no attribute 'click'. I read a lot of similar posts, but wasn't able to fix my problem.. so I assume that javascript event must be called/clicked/performed somehow differnt.. idk Im stuck

                from selenium import webdriver
                link = 'https://www.investing.com/equities/apple-computer-inc-balance-sheet'
                
                driver = webdriver.Firefox()
                driver.get(link)
                elm = driver.find_elements_by_xpath("/html/body/div[5]/section/div[8]/div[1]/a[1]").click()
                

                html 如下:

                <a class="newBtn toggleButton LightGray" href="javascript:void(0);" data-type="rf-type-button" data-ptype="Annual" data-pid="6408" data-rtype="BAL">..</a>
                

                推薦答案

                我仍然建議你使用 linkText 而不是 XPATH.這個 xpath 的原因: /html/body/div[5]/section/div[8]/div[1]/a[1] 非常絕對,如果有 可能會失敗又一個 div 添加從 HTML 中刪除.而更改鏈接文本的機會非常小.

                I would still suggest you to go with linkText over XPATH. Reason this xpath : /html/body/div[5]/section/div[8]/div[1]/a[1] is quite absolute and can be failed if there is one more div added or removed from HTML. Whereas chances of changing the link Text is very minimal.

                所以,而不是這個代碼:

                elm = driver.find_elements_by_xpath("/html/body/div[5]/section/div[8]/div[1]/a[1]").click()
                

                試試這個代碼:

                annual_link = driver.find_element_by_link_text('Annual')
                annual_link.click()
                

                是的,@Druta 是對的,將 find_element 用于一個 Web 元素,將 find_elements 用于 Web 元素列表.顯式等待總是好的.

                and yes @Druta is right, use find_element for one web element and find_elements for list of web element. and it is always good to have explicit wait.

                像這樣創建顯式等待的實例:

                Create instance of explicit wait like this :

                wait = WebDriverWait(driver,20)
                

                并像這樣使用等待引用:

                and use the wait reference like this :

                wait.until(EC.elementToBeClickable(By.LINK_TEXT, 'Annual'))  
                

                更新:

                from selenium import webdriver
                link = 'https://www.investing.com/equities/apple-computer-inc-balance-sheet'
                
                driver = webdriver.Firefox()
                driver.maximize_window()
                wait = WebDriverWait(driver,40)
                driver.get(link)  
                
                driver.execute_script("window.scrollTo(0, 200)") 
                
                wait.until(EC.element_to_be_clickable((By.LINK_TEXT, 'Annual')))
                annual_link = driver.find_element_by_link_text('Annual')
                annual_link.click()
                print(annual_link.text)  
                

                確保導入這些:

                from selenium.webdriver.common.keys import Keys
                from selenium.webdriver.common.by import By
                from selenium.webdriver.support.ui import WebDriverWait
                from selenium.webdriver.support import expected_conditions as EC 
                

                這篇關于AttributeError: 'list' 對象沒有使用 Selenium 和 Python 的屬性 'click'的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調用完成)
                JavaScript innerHTML is not working for IE?(JavaScript innerHTML 不適用于 IE?)
                XMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 無法加載,請求的資源上不存在“Access-Control-Allow-Origin標頭) - IT屋-程序員軟件開發技術分
                Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請求是否有可能不遵循重定向 (301 302))
                XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內容)
                Restrictions of XMLHttpRequest#39;s getResponseHeader()?(XMLHttpRequest 的 getResponseHeader() 的限制?)
                    • <i id='GeDmm'><tr id='GeDmm'><dt id='GeDmm'><q id='GeDmm'><span id='GeDmm'><b id='GeDmm'><form id='GeDmm'><ins id='GeDmm'></ins><ul id='GeDmm'></ul><sub id='GeDmm'></sub></form><legend id='GeDmm'></legend><bdo id='GeDmm'><pre id='GeDmm'><center id='GeDmm'></center></pre></bdo></b><th id='GeDmm'></th></span></q></dt></tr></i><div class="jr5px5l" id='GeDmm'><tfoot id='GeDmm'></tfoot><dl id='GeDmm'><fieldset id='GeDmm'></fieldset></dl></div>

                        <tfoot id='GeDmm'></tfoot>

                        <small id='GeDmm'></small><noframes id='GeDmm'>

                        <legend id='GeDmm'><style id='GeDmm'><dir id='GeDmm'><q id='GeDmm'></q></dir></style></legend>
                        • <bdo id='GeDmm'></bdo><ul id='GeDmm'></ul>
                            <tbody id='GeDmm'></tbody>
                          主站蜘蛛池模板: 井式炉-台车式回火炉-丹阳市电炉厂有限公司 | 上海单片机培训|重庆曙海培训分支机构—CortexM3+uC/OS培训班,北京linux培训,Windows驱动开发培训|上海IC版图设计,西安linux培训,北京汽车电子EMC培训,ARM培训,MTK培训,Android培训 | 耐磨陶瓷,耐磨陶瓷管道_厂家-淄博拓创陶瓷科技 | 办公室家具_板式办公家具定制厂家-FMARTS福玛仕办公家具 | 北京亦庄厂房出租_经开区产业园招商信息平台 | 知名电动蝶阀,电动球阀,气动蝶阀,气动球阀生产厂家|价格透明-【固菲阀门官网】 | 哈希PC1R1A,哈希CA9300,哈希SC4500-上海鑫嵩实业有限公司 | 泉州陶瓷pc砖_园林景观砖厂家_石英砖地铺石价格 _福建暴风石英砖 | 诗词大全-古诗名句 - 古诗词赏析| 检验科改造施工_DSA手术室净化_导管室装修_成都特殊科室建设厂家_医疗净化工程公司_四川华锐 | 中药二氧化硫测定仪,食品二氧化硫测定仪|俊腾百科 | 高考志愿规划师_高考规划师_高考培训师_高报师_升学规划师_高考志愿规划师培训认证机构「向阳生涯」 | 塑料检查井_双扣聚氯乙烯增强管_双壁波纹管-河南中盈塑料制品有限公司 | 智慧钢琴-电钢琴-便携钢琴-数码钢琴-深圳市特伦斯乐器有限公司 | 济南侦探调查-济南调查取证-山东私家侦探-山东白豹调查咨询公司 密集架|电动密集架|移动密集架|黑龙江档案密集架-大量现货厂家销售 | 威客电竞(vk·game)·电子竞技赛事官网| 济南品牌包装设计公司_济南VI标志设计公司_山东锐尚文化传播 | 京马网,京马建站,网站定制,营销型网站建设,东莞建站,东莞网站建设-首页-京马网 | 上海电子秤厂家,电子秤厂家价格,上海吊秤厂家,吊秤供应价格-上海佳宜电子科技有限公司 | 周口风机|周风风机|河南省周口通用风机厂| 搪瓷反应釜厂家,淄博搪瓷反应釜-淄博卓耀 | 【甲方装饰】合肥工装公司-合肥装修设计公司,专业从事安徽办公室、店面、售楼部、餐饮店、厂房装修设计服务 | 西安微信朋友圈广告投放_微信朋友圈推广_西安度娘网络科技有限公司 | 压缩空气检测_气体_水质找上海京工-服务专业、价格合理 | 家用净水器代理批发加盟_净水机招商代理_全屋净水器定制品牌_【劳伦斯官网】 | 集装箱标准养护室-集装箱移动式养护室-广州璟业试验仪器有限公司 | 恒温恒湿箱(药品/保健品/食品/半导体/细菌)-兰贝石(北京)科技有限公司 | 车充外壳,车载充电器外壳,车载点烟器外壳,点烟器连接头,旅行充充电器外壳,手机充电器外壳,深圳市华科达塑胶五金有限公司 | 高温高压釜(氢化反应釜)百科 | 济南ISO9000认证咨询代理公司,ISO9001认证,CMA实验室认证,ISO/TS16949认证,服务体系认证,资产管理体系认证,SC食品生产许可证- 济南创远企业管理咨询有限公司 郑州电线电缆厂家-防火|低压|低烟无卤电缆-河南明星电缆 | 仿清水混凝土_清水混凝土装修_施工_修饰_保护剂_修补_清水混凝土修复-德州忠岭建筑装饰工程 | 拉曼光谱仪_便携式|激光|显微共焦拉曼光谱仪-北京卓立汉光仪器有限公司 | 钢板仓,大型钢板仓,钢板库,大型钢板库,粉煤灰钢板仓,螺旋钢板仓,螺旋卷板仓,骨料钢板仓 | HYDAC过滤器,HYDAC滤芯,现货ATOS油泵,ATOS比例阀-东莞市广联自动化科技有限公司 | 压砖机_电动螺旋压力机_粉末成型压力机_郑州华隆机械tel_0371-60121717 | 乳化沥青设备_改性沥青设备_沥青加温罐_德州市昊通路桥工程有限公司 | 电磁铁_小型推拉电磁铁_电磁阀厂家-深圳市宗泰电机有限公司 | 橡胶膜片,夹布膜片,橡胶隔膜密封,泵阀设备密封膜片-衡水汉丰橡塑科技公司网站 | cnc精密加工_数控机械加工_非标平键定制生产厂家_扬州沃佳机械有限公司 | YAGEO国巨电容|贴片电阻|电容价格|三星代理商-深圳市巨优电子有限公司 | 流量检测仪-气密性检测装置-密封性试验仪-东莞市奥图自动化科技有限公司 |