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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

有什么辦法可以點(diǎn)擊同一個(gè)圖標(biāo)嗎?

有什么辦法可以點(diǎn)擊同一個(gè)圖標(biāo)嗎?

胡子哥哥 2023-10-06 11:10:38
我想從頁(yè)面中單擊“進(jìn)行中的球門線”下的所有矩形圖標(biāo)(圖標(biāo)看起來(lái)像足球場(chǎng))。我嘗試了很多次但沒(méi)有成功。如果有人知道如何單擊這些所有圖標(biāo),請(qǐng)幫助我。from time import sleepfrom selenium import webdriverfrom selenium.webdriver.chrome.options import Optionschrome_options = Options()# chrome_options.add_argument("--headless")chrome_options.add_argument('--start-maximized')driver = webdriver.Chrome(options=chrome_options, executable_path=r"chromedriver.exe")driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {"source": """Object.defineProperty(navigator, 'webdriver', {get: () => undefined})"""})url = 'https://www.bet365.com/#/IP/B1'driver.get(url)sleep(10)res = driver.execute_script("return document.documentElement.outerHTML")sleep(10)click_icon = driver.find_element_by_css_selector(".ovm-MediaIconContainer_Buttons div")click_icon.click()
查看完整描述

1 回答

?
aluckdog

TA貢獻(xiàn)1847條經(jīng)驗(yàn) 獲得超7個(gè)贊

(移動(dòng)評(píng)論來(lái)回答)

兩個(gè)問(wèn)題:

  • 您正在使用 搜索類和標(biāo)簽find_element_by_css_selector。將此更改為僅搜索類名。

  • 要返回元素集合,請(qǐng)使用find_elements_by_css_selectorit 返回元素列表。

替換這段代碼:

click_icon = driver.find_element_by_css_selector(".ovm-MediaIconContainer_Buttons div")
click_icon.click()

有了這個(gè):

icon_list = driver.find_elements_by_css_selector(".ovm-MediaIconContainer_Buttons")
for icon in icon_list:  # every icon in list
    icon.click()  # click single icon


查看完整回答
反對(duì) 回復(fù) 2023-10-06
  • 1 回答
  • 0 關(guān)注
  • 134 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)