使用selenium-Python单击一个div

使用selenium-Python单击一个div,python,selenium,Python,Selenium,该网站是: 如果单击下图中的任何项目,您将在该选择上获得一个绿色勾号。请参见这两幅图 选择后: 我无法使用selenium执行此单击操作。 这就是我正在尝试的: driver.get("https://www.smile.one/merchant/mobilelegends?source=other") driver.find_element_by_xpath("//div[@class='sectionNav-cartao n107002' and @ga-d

该网站是:

如果单击下图中的任何项目,您将在该选择上获得一个绿色勾号。请参见这两幅图

选择后:

我无法使用selenium执行此单击操作。

这就是我正在尝试的:

driver.get("https://www.smile.one/merchant/mobilelegends?source=other")
driver.find_element_by_xpath("//div[@class='sectionNav-cartao n107002' and @ga-data='1717']").click()
这引发了一个例外:

raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotVisibleException: Message: element not interactable
我还尝试使用inspect元素使用精确的直接路径:

WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "body > mate > div.main-container > section > div.section-nav > div.sectionNav-list > div.sectionNav-cartao.n107002"))).click()
并得到一个
超时
错误

我也试过其他几种方法,但似乎都不管用

如何执行此单击?

如果要使用
XPath=“//div[@class='sectionNav-cartao n107002'和@ga data='1717']”
则有两个元素具有相同的XPath。使用独特的XPath,如
XPath=“//div[@class='pc-nav']//div[@class='sectionNav-cartao n107002'和@ga data='1717']”
,它在chrome开发工具中只突出显示一个元素

代码:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Chrome()
driver.get("https://www.smile.one/merchant/mobilelegends?source=other")
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@class='pc-nav']")))

element = driver.find_element(By.XPATH, "//div[@class='pc-nav']//div[@class='sectionNav-cartao n107002' and @ga-data='1717']").click()