久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何使用 Selenium 和 Python 定位具有多個類名的元

How to locate an element with multiple classnames using Selenium and Python(如何使用 Selenium 和 Python 定位具有多個類名的元素)
本文介紹了如何使用 Selenium 和 Python 定位具有多個類名的元素的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試單擊類名等于 "clean right" 的以下元素:

I'm trying to click on the following element with the class name equals "clean right":

<li class="clean right"></li>

如何使用 driver.find_element_by_class_name()

推薦答案

你不能通過 find_element_by_class_name() 傳遞多個類名作為參數(shù),這樣做你會遇到如下錯誤:

You can't pass multiple classnames as argument through find_element_by_class_name() and doing so you will face an error as:

invalid selector: Compound class names not permitted

<小時>

有多種方法可以解決此用例,您可以使用以下任一方法定位器策略:

  • 如果元素僅通過 classname clean 唯一標識,您可以使用:

  • If the element is uniquely identified only through the classname clean you can use:

driver.find_element_by_class_name("clean")

  • 如果元素僅通過 classname right 唯一標識,您可以使用:

  • If the element is uniquely identified only through the classname right you can use:

    driver.find_element_by_class_name("right")
    

  • 如果 classnamescleanright 都是強制標識元素,你可以使用 css-選擇器如下:

    driver.find_element_by_css_selector("li.clean.right")
    

  • 您也可以使用 xpath 如下:

    driver.find_element_by_xpath("http://li[@class='clean right']")
    

  • 無效選擇器:復合類名稱不允許使用 Selenium 的錯誤

    通過多個類名查找 div 元素?

    這篇關于如何使用 Selenium 和 Python 定位具有多個類名的元素的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

    相關文檔推薦

    How to draw a rectangle around a region of interest in python(如何在python中的感興趣區(qū)域周圍繪制一個矩形)
    How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測和跟蹤人員?)
    How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個矩形邊界框中應用閾值?)
    How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
    Detect image orientation angle based on text direction(根據(jù)文本方向檢測圖像方向角度)
    Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測圖像中矩形的中心和角度)
    主站蜘蛛池模板: av色在线 | √天堂资源地址在线官网 | 毛片在线免费播放 | 大尺度做爰呻吟舌吻网站 | 亚洲欧美日韩一区二区三区四区 | 综合色在线 | 久久免费观看视频 | 男女啪啪免费视频 | 黄色小视频在线免费观看 | 丁香色婷婷| 激情久久五月天 | 亚洲精品免费观看 | 看毛片的网站 | 黄色一级片免费 | 国产精品偷乱一区二区三区 | 青青国产 | 夜夜肉她怀孕h周君彦 | 国产精品久久久999 成人在线国产 | 欧美午夜理伦三级在线观看 | 中文天堂网 | 午夜福利毛片 | 一级黄色片视频 | 国产精品天美传媒入口 | 欧美一级特黄aa大片 | 五月激情综合网 | 日韩影院在线观看 | 久久成人免费视频 | 国产无遮挡又黄又爽免费网站 | 成人看片网 | 日韩欧美在线播放 | 国产一区二区av | 最新日韩在线 | 亚洲一区免费观看 | 国产精品网站在线观看 | 亚洲国产精品久久 | 日本国产视频 | 午夜av片| 99视频网 | www黄色片 | 一级黄色片免费看 | 黄色录像大片 |