在定位某一元素,必须是鼠标悬浮上,才会出现,然后才能点击的情况。
首先导入需要的模块:
import time
from selenium.webdriver import ActionChains
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
定位需要的元素:
ActionChains(driver).move_to_element(driver.find_element(By.XPATH,'//*[@id="assetType_7"]')).perform()
data_click = WebDriverWait(driver, 5).until(
EC.element_to_be_clickable((By.XPATH, '//*[@id="sourceId_125"]'))
)
进行点击操作:
data_click.click()