一、如果元素不能通过selenium的click来进行点击操作,解决方案有哪些
1、通过模拟鼠标来进行操作
import time
from selenium.webdriver.common.by import By
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
driver = webdriver.Chrome()
#隐示等待
driver.implicitly_wait(5)
driver.get("https://mail.163.com/")
driver.maximize_window()
#由于网易的iframe的id属性是用随机数生成的,所以这里我们使用tag_name去定位
eles =driver.find_elements(By.TAG_NAME,"iframe")
driver.switch_to.frame(eles[0])
time.sleep(1)
driver.find_element(By.XPATH,'//input[@data-placeholder="邮箱帐号或手机号码"]').send_keys("xijiao19880516")
driver.find_element(By.XPATH,'//input[@data-placeholder="输入密码"and @ name="password"]').send_keys("11.0")
#实例化ActionChains类
action = ActionChains(driver=driver)
#使用使用鼠标的点击操作
ele = driver.find_element(By.XPATH,'//a[@id="dologin"]&#