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

不允許使用硒化合物類名稱

Selenium Compound class names not permitted(不允許使用硒化合物類名稱)
本文介紹了不允許使用硒化合物類名稱的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我有下面的代碼,點(diǎn)擊一個(gè)元素彈出一個(gè)屏幕并復(fù)制其中的文本

el1 = driver.find_element_by_id("keyDev-A")el1.click()el2 = driver.find_element_by_class_name(內(nèi)容")打印(el2.text)

但是,當(dāng)我試圖讓 selenium

點(diǎn)擊該彈出窗口中的按鈕時(shí)

el3 = driver.find_element(By.CLASS_NAME, "action-btn cancel alert-display")el3.??click()

它會(huì)產(chǎn)生一條錯(cuò)誤消息:

無效的選擇器:不允許復(fù)合類名

這是我試圖讓 selenium 點(diǎn)擊的 HTML.關(guān)閉按鈕.

我應(yīng)該如何編寫 el3 才能點(diǎn)擊 關(guān)閉 按鈕?

解決方案

Leon's注釋 導(dǎo)致不再支持復(fù)合類名稱的正確信息.你可以做的是嘗試使用 css 選擇器.在您的情況下,以下代碼行應(yīng)該可以幫助您獲得所需的元素:

el3 = driver.find_element_by_css_selector(".action-btn.cancel.alert-display")

它在 class 屬性中找到具有所有三個(gè)類(action-btn、cancel 和 alert-display)的元素.請(qǐng)注意,類的順序在這里無關(guān)緊要,任何類都可能出現(xiàn)在類屬性中的任何位置.只要元素具有所有三個(gè)類,它就會(huì)被選中.如果要固定類的順序,可以使用以下 xpath :

el3 = driver.find_element_by_xpath("http://*[@class='action-btn cancel alert-display']")

I have the below code that clicks on an element to pop up a screen and copy the text in it

el1 = driver.find_element_by_id("keyDev-A")
el1.click()
el2 = driver.find_element_by_class_name("content")
print(el2.text)

However, when I tried to get selenium to click on the button within that popup with

el3 = driver.find_element(By.CLASS_NAME, "action-btn cancel alert-display")
el3.click()

It produces an error message:

invalid selector: Compound class names not permitted

This is the HTML that I am trying to get selenium to click on. The Close button.

<div class="nav">
    <span class="action-btn confirm prompt-display">Confirm</span>
    <span class="action-btn cancel prompt-display">Cancel</span>
    <span class="action-btn cancel alert-display">Close</span>
</div>

How should I be writing el3 in order to click on the Close button?

解決方案

Leon's comment leads to the correct information that compound class names are no longer supported. What you could do instead is try using css selectors. In your case, the following line of code should help you get the element you want :

el3 = driver.find_element_by_css_selector(".action-btn.cancel.alert-display")

It finds the element with all three classes (action-btn, cancel and alert-display) in the class attribute. Do note that the order of the classes does not matter here and any of the classes may appear anywhere in the class attribute. As long as the element has all three classes, it will be selected. If you want the order of the classes to be fixed, you can use the following xpath :

el3 = driver.find_element_by_xpath("http://*[@class='action-btn cancel alert-display']") 

這篇關(guān)于不允許使用硒化合物類名稱的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

How to draw a rectangle around a region of interest in python(如何在python中的感興趣區(qū)域周圍繪制一個(gè)矩形)
How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測和跟蹤人員?)
How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個(gè)矩形邊界框中應(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 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 亚洲国产精品va在线看黑人 | 国产精品欧美一区二区三区不卡 | 国产在线一区二区三区 | 久久久久久国产精品免费免费狐狸 | 国产成人综合网 | 久久久久国| 成人深夜福利在线观看 | 一区二区中文字幕 | 激情毛片| 日本中文字幕在线观看 | 亚洲一区二区在线视频 | 久久精彩视频 | 亚洲精品乱码久久久久久按摩观 | 精品综合 | 毛片com | 日本亚洲一区 | 欧美视频偷拍 | 国产专区在线 | 亚洲av毛片| 免费簧片视频 | 福利网站导航 | 国产黄视频在线播放 | 国产精品免费观看 | 精品福利av导航 | 超碰成人免费 | 亚洲精品欧美 | 天天插天天干 | 午夜成人在线视频 | 欧美白人做受xxxx视频 | 久久久tv| 一区二区不卡 | 国产精品免费观看视频 | 精品国产乱码久久久久久丨区2区 | 欧美精品在欧美一区二区 | 精品视频在线观看 | 在线观看视频91 | 欧美成人a | 自拍偷拍第一页 | 免费一级黄色电影 | 国产日韩一区二区三区 | 久久久www成人免费无遮挡大片 |