【问题标题】:Can anyone help me , My selenium browser is closing itself in python谁能帮助我,我的硒浏览器在 python 中关闭了自己
【发布时间】:2022-09-23 18:58:07
【问题描述】:

当我运行文件时,它会自动关闭而不需要 driver.close()


driver = webdriver.Chrome()
driver.get(\"https://www.roblox.com/login\")
searchbox = driver.find_element(\"xpath\",\'//*[@id=\"login-username\"]\')
searchbox.send_keys(\"ade\")
passwordsearch = driver.find_element(\"xpath\",\'//*[@id=\"login-password\"]\')
passwordsearch.send_keys(\"abcde\")

  • 也发布堆栈错误。似乎 chromedriver 版本与 chrome 浏览器版本不兼容。

标签: python selenium


【解决方案1】:

您必须使用“分离”选项添加ChromeOptions(),以防止浏览器窗口自动关闭。

options = Options()
options.add_experimental_option('detach', True)
driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()), options = options)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-10-27
    • 2011-12-09
    • 2011-08-09
    • 2017-03-27
    • 1970-01-01
    • 1970-01-01
    • 2019-12-17
    相关资源
    最近更新 更多