用的selenium为什么无法点击这个按钮呢


import time

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome import service
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

options = Options()
options.add_argument('user-data-dir=/Users/ddgg/Library/Application Support/Google/Chrome/Profile 1')
PATH = '/Users/ddgg/Desktop/chromedriver'
drive = webdriver.Chrome(service=service.Service(PATH, 0, None, None), chrome_options=options)
drive.get("https://monaconft.io/login/wallet")

try:
    element.click()
    element = WebDriverWait(drive, 10).until(
        EC.presence_of_element_located((By.XPATH, '<//div[contains(@class,"name")]'))
    )
    element.click()
except:
    time.sleep(5)
    print ('no such element')

⬆️代码

profile 1里需要的插件我已经装好了,直接登录的profile1
还需要再加载一次插件吗?
如果需要登录插件该如何通过selenium调用出来呢

img


element 都还没赋值,就先click 啦?

selenium 可能会有部分标签无法点击的情况,一般遇到这种情况,就用 JS 来点击就好了,之前也有遇到过这个问题,有些是偶尔出现,有些是 selenium 处理不了的。
可以用以下 JS 进行点击
webdriver.execute_script("$(arguments[0]).click()", ele)