亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Selenium 在 div 中查找類

Selenium 在 div 中查找類

侃侃無極 2023-08-21 19:41:18
我正在嘗試通過 python 中的 selenium 訪問并單擊“X”按鈕,以便能夠重定向到下一頁并從中加載一些信息。但是,我很難找到該元素,不知道是因為在類中還是其他原因。你們能幫我實際點擊按鈕嗎?下面的代碼是我目前擁有的。先感謝您:from selenium.webdriver import Firefoxfrom selenium.webdriver.firefox.options import Optionsimport timefrom selenium import webdriverdriver = webdriver.Firefox()url = 'https://shop.axs.co.uk/Lw%2fYCwAAAAA6dpvSAAAAAABB%2fv%2f%2f%2fwD%2f%2f%2f%2f%2fBXRoZW8yAP%2f%2f%2f%2f%2f%2f%2f%2f%2f%2f'opts = Options()browser = Firefox(options=opts)browser.get(url)#wait for all elements to loadtime.sleep(5)#working lines are commented out#search_form = browser.find_element_by_class_name("modal-open")browser.find_element_by_class_name('btn-close-svg pull-right').click()
查看完整描述

1 回答

?
一只斗牛犬

TA貢獻1784條經驗 獲得超2個贊

刪除此行 -

opts = Options() browser = Firefox(options=opts)

在這里使用 xpath-

driver.find_element_by_xpath(".//div[@class='btn-close-svg pull-right']").click()


查看完整回答
反對 回復 2023-08-21
  • 1 回答
  • 0 關注
  • 106 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號