我的python代码显示对的,但是运行时不显示浏览器页面呢?

from selenium.webdriver import ActionChains
from selenium import webdriver
from selenium.webdriver.common.by import By
import time

driver = webdriver.Chrome()
driver.get("https://kyfw.12306.cn/otn/resources/login.html")

ac = driver.find_element(By.XPATH,'//*[@id="J-userName"]')
ActionChains(driver).move_to_element(ac).click(ac).perform()
time.sleep(2)
ac.send_keys("")#账号()

ac = driver.find_element(By.XPATH,'//*[@id="J-password"]')
ActionChains(driver).move_to_element(ac).click(ac).perform()
time.sleep(2)
ac.send_keys("")#密码()

ac = driver.find_element(By.XPATH,'//*[@id="J-login"]')
ActionChains(driver).move_to_element(ac).click(ac).perform()
time.sleep(5)

ac = driver.find_element(By.XPATH,'//*[@id="J-index"]/a')
ActionChains(driver).move_to_element(ac).click(ac).perform()
time.sleep(5)

ac = driver.find_element(By.XPATH,'//*[@id="fromStationText"]')
ActionChains(driver).move_to_element(ac).click(ac).perform()
time.sleep(2)
ac.send_keys("无锡")

ac = driver.find_element(By.XPATH,'//*[@id="citem_0"]/span[1]')
ActionChains(driver).move_to_element(ac).click(ac).perform()

ac = driver.find_element(By.XPATH,'//*[@id="toStationText"]')
ActionChains(driver).move_to_element(ac).click(ac).perform()
time.sleep(2)
ac.send_keys("北京")

ac = driver.find_element(By.XPATH,'//*[@id="citem_2"]')
ActionChains(driver).move_to_element(ac).click(ac).perform()

ac = driver.find_element(By.XPATH,'//*[@id="search_one"]')
ActionChains(driver).move_to_element(ac).click(ac).perform()
time.sleep(2)

你程序运行应该有运行信息,你看看有没有异常

代码没问题,浏览器可以打开

你运行有什么错误信息吗?
是不是Selenium 的Chrome驱动没有安装
参考这个安装下Chrome驱动

img

如有帮助,请点击我的回答下方的【采纳该答案】按钮帮忙采纳下,谢谢!

img