美文网首页
自动安装selenium-driver

自动安装selenium-driver

作者: 沈宥 | 来源:发表于2022-09-23 17:54 被阅读0次

    一、安装

    1、Git地址:https://github.com/SergeyPirogov/webdriver_manager
    2、安装

    pip install webdriver-manager

    二、使用教程

    以Chromedriver为例

    # selenium 3
    from selenium import webdriver
    from webdriver_manager.chrome import ChromeDriverManager
    
    driver = webdriver.Chrome(ChromeDriverManager().install())
    
    # selenium 4
    from selenium import webdriver
    from selenium.webdriver.chrome.service import Service as ChromeService
    from webdriver_manager.chrome import ChromeDriverManager
    
    driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))
    

    三、其他支持的浏览器

    Firefox
    # selenium 3
    from selenium import webdriver
    from webdriver_manager.firefox import GeckoDriverManager
    
    driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())
    
    
    Edge
    # selenium 3
    from selenium import webdriver
    from webdriver_manager.microsoft import EdgeChromiumDriverManager
    
    driver = webdriver.Edge(EdgeChromiumDriverManager().install())
    
    Chromium
    # selenium 3
    from selenium import webdriver
    from webdriver_manager.chrome import ChromeDriverManager
    from webdriver_manager.core.utils import ChromeType
    
    driver = webdriver.Chrome(ChromeDriverManager(chrome_type=ChromeType.CHROMIUM).install())
    

    相关文章

      网友评论

          本文标题:自动安装selenium-driver

          本文链接:https://www.haomeiwen.com/subject/pwmnortx.html