有关于python+selenium运行代码—— 问卷星自动抢讲座,谷歌浏览器出现闪退的问题


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


def autoFillSpace(username,sid,phone,dept,myclass):
    chromeOptions = webdriver.ChromeOptions()  # 实例化
    browser = webdriver.Chrome(options=chromeOptions)
    wait = WebDriverWait(browser, 3)  # 等待时间

    browser.get(url) # 获取问卷星 url

    # 问卷详情
    # 您的姓名
    usernameIn = wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="q1"]'))) # F12查看,匹配对应的id
    usernameIn.clear()
    usernameIn.send_keys(username) # 这个传入的参数不能跟上面的对象重复

    # 学号
    sidIn = wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="q2"]')))
    sidIn.clear()
    sidIn.send_keys(sid)

    # 电话号码
    phoneIn = wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="q3"]')))
    phoneIn.clear()
    phoneIn.send_keys(phone)

    # 所在学院
    deptIn = wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="q4"]')))
    deptIn.clear()
    deptIn.send_keys(dept)

    # 专业班级(xx专业xx班)
    myclassIn = wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="q5"]')))
    myclassIn.clear()
    myclassIn.send_keys(myclass)



    # 提交
    submit = wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="ctlNext"]')))
    submit.click()



if __name__ == '__main__':
    url ='https://www.wjx.top/vm/hoOgiJ3.aspx'  # 问卷星的链接
    username = '小明'  # 您的姓名
    sid = '20210901'  # 学号
    phone = '13200000001'  # 电话号码
    dept = 'xx学院'   # 所在学院
    myclass = 'xx1班'   # 专业班级(xx专业xx班)


    autoFillSpace(username,sid,phone,dept,myclass)

chrome和驱动版本是匹配 的
我尝试网上的各种方法,结果还是解决不了
想让这个python代码正常运行的时候 谷歌浏览器不会闪退

说实话,我运行了一遍,没有问题,你可以试试重装浏览器和chromedriver