【help】求selenium安装驱动版本和浏览器版本一样,可以调用driver打开后几秒会闪退,但是使用time.sleep(300),可以增加开启时间,但是无法使用driver.find_element(By.XPATH)或者driver.find_element(By.ID,'pwd').定位键入,两次代码如下,先用XPATH然后使用ID都无法正常运行
-- coding: UTF-8 --
import time
from selenium.webdriver.common.by import By
from selenium.webdriver import Edge
from selenium.webdriver.common.keys import Keys
web = Edge()
web.get('http://xscfw.hebust.edu.cn/survey/login')
print('1')
time.sleep(1)
print('2')
web.find_element(By.ID,'stuNum').send_keys('27')
time.sleep(1)
print('3')
web.find_element(By.ID,'pwd').send_keys('L**00')
print('4')
web.find_element(By.XPATH,'/html/body/div[1]/div[2]/div/div/button').click()
#time.sleep(1)
#web.find_element(By.XPATH,'/html/body/div[1]/div[2]/form/div[1]')..send_keys('2108010527')
#time.sleep(1)
#web.find_element(By.XPATH,'/html/body/div[1]/div[2]/form/div[2]').send_keys('Lc2#0000000000')
#time.sleep(1)
#web.find_element(By.XPATH,'/html/body/div[1]/div[2]/div/div/button').click()
#time.sleep(3)
web.close()
内容报错如下图