【问题标题】:Changing download directory for edge using Python selenium使用 Python selenium 更改边缘的下载目录
【发布时间】:2022-06-12 18:19:22
【问题描述】:

我可以使用 Python Selenium 更改 Chrome 的下载目录,如下所示:

DownloadPath = (f'C:\\Users\\{EmplyID}\\Desktop\\General Orders\\{Newfolder}')
chromeOptions = Options()
chromeOptions.add_experimental_option("prefs", {"download.default_directory": DownloadPath})

driver = webdriver.Chrome(executable_path=f'C:\\Users\\{EmplyID}\\Desktop\\General 
Orders\\Bidman To Enovia\\chromedriver.exe',options=chromeOptions)

但我无法为边缘网络驱动程序做同样的事情。如果有人可以帮助我编写代码,那就太好了。

提前致谢。 :)

【问题讨论】:

    标签: python selenium selenium-webdriver microsoft-edge selenium-edgedriver


    【解决方案1】:
     1. Download the correct version of Edge WebDriver from [here][1]. Make
        sure that the Edge WebDriver version is the same as the Edge browser
        version.
    
      [1]: https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
    
    
     2. Install the MS Edge Selenium tools using command below:
    
        `pip install msedge-selenium-tools selenium==version e.eg 3.141.4`
    
     3. Run the following sample python code to test:
    
        from msedge.selenium_tools import Edge, EdgeOptions
        
        options = EdgeOptions()
            
        options.use_chromium = True
            
        options.add_experimental_option("prefs", {"download.default_directory": r"D:\Downloads"})
        
        
        driver = Edge(executable_path=r"D:\webdriver\msedgedriver.exe", options=options)
            
        driver.get("https://www.seleniumhq.org/download/");
            
        m = driver.find_element_by_link_text("32 bit Windows IE")
            
        m.click()
    
    
    **Note**: Change the paths in the code to your owns.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-11
      • 1970-01-01
      • 2022-08-14
      • 1970-01-01
      • 2021-04-13
      • 2013-08-04
      • 2020-05-26
      • 1970-01-01
      相关资源
      最近更新 更多