Change the default file download path for Edge using selenium

可紊 提交于 2021-02-08 10:46:28

问题


I was using selenium-ruby for automating browser application. I want to simulate file download scenario. When I want to execute for chrome I had a method named "download_path", its value can be changed at run-time and when download file it will be saved at my destination path.

But, when I execute the same code for edge there is no method support for "download_path" in edge.

Is there any way to set my default download location at runtime?

Chrome Code:

@browser = Selenium::WebDriver.for :chrome

# code for navigating to downloads page and clicking on download button

@browser.download_path = File.dirname(filePath)
@browser.close

Edge Code:

@browser = Selenium::WebDriver.for :edge

# code for navigating to downloads page and clicking on download button


@browser.download_path = File.dirname(filePath)
@browser.close

Error

Error: test_01_click_download_pass(Download_A_File): NoMethodError: undefined method `download_path=' for #<Selenium::WebDriver::EdgeHtml::Driver:0x0000000004cdd8a0>

Environment Details:

OS: Windows 10
Programming Language: ruby (v2.5.5)
Gem : selenium-webdriver (v alpha4)

回答1:


After checking the selenium EdgeDriver library and the Microsoft Edge WebDriver document, it seems that there is no way to set the change the download file path via the selenium Edge webdriver.

I suggest you could directly change the default download location in Edge via the Edge settings. Besides, you could also try to change the Edge browser setting through change the Registry. More detail information, please check the following link:

Change default download location in Edge



来源:https://stackoverflow.com/questions/59934307/change-the-default-file-download-path-for-edge-using-selenium

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!