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

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

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

問題描述

我正在嘗試單擊類名等于 "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']")
    

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

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

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

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

    相關(guā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?(如何在圖像的多個矩形邊界框中應(yīng)用閾值?)
    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 檢測圖像中矩形的中心和角度)
    主站蜘蛛池模板: 国产视频不卡一区 | 国产黄色大片 | 91久久看片 | 国产精品精品视频一区二区三区 | jizz视频| www.888www看片 | 操久久 | 精品久久久久香蕉网 | 中文字幕免费在线 | 成人性视频在线播放 | 免费日韩av | 久久香焦| 美女天天干天天操 | 黄色av观看| 看一级黄色毛片 | 欧美黄色片| 超碰av免费 | 欧美日韩电影一区二区 | 精品亚洲一区二区 | 国产一区二区三区亚洲 | 精品三区 | 成人超碰在线 | 国产成人精品久久二区二区 | 久久久久久免费精品一区二区三区 | 日韩成人免费在线视频 | 国产精品一区二区三区久久 | 国产成人免费在线 | 午夜三级视频 | 久草精品视频 | 九九热在线观看视频 | gav成人免费播放视频 | 欧美乱操 | 国产在线精品一区二区 | 国产成人精品区一区二区不卡 | 欧美成人影院在线 | 亚洲精品久久久一区二区三区 | 久久国产精品久久久久久久久久 | 免费一区二区在线观看 | 久久久精品视频免费看 | 干干干操操操 | 亚洲一区不卡在线 |