代码之家  ›  专栏  ›  技术社区  ›  Mykola Zotko

如何将selenium webdriver从无头模式设置为正常模式?

  •  0
  • Mykola Zotko  · 技术社区  · 6 年前

    在将selenium webdriver设置为无头模式后,是否可以将其设置回正常模式?

    from selenium import webdriver
    from selenium.webdriver.firefox.options import Options
    
    options = Options()
    options.headless = True
    driver = webdriver.Firefox(options=options)
    driver.get(http://stackoverflow.com)
    
    # set driver back to normal mode
    
    0 回复  |  直到 6 年前
        1
  •  3
  •   undetected Selenium    5 年前

    ,不可能使Chrome在 无头 模式,然后在同一会话中切换回正常模式。

    铬河 具有 ChromeOptions() 跨越一个新的 配置获取 铬河 可执行文件,将在 以及存在 不可编辑 . 所以你不能修改/添加任何现有的/新的 配置 通过 班级到 当前正在执行的实例。

    即使你能提取 色度测定 属性,例如。 会话ID , , 用户代理 以及已启动的 铬河 仍然无法更改 .

    更干净的方法是打电话 driver.quit() tearDown(){} 方法到 关闭 破坏 电流 Chrome浏览器 实例优雅地跨越一组新的 使用新配置集的实例。


    tl;博士