问题描述
我使用 selenium-ruby 来自动化浏览器应用程序.我想模拟文件下载场景.当我想为 chrome 执行时,我有一个名为download_path"的方法,它的值可以在运行时更改,下载文件时它将保存在我的目标路径中.
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.
但是,当我为 edge 执行相同的代码时,edge 中没有对download_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 代码:
@browser = Selenium::WebDriver.for :chrome
# code for navigating to downloads page and clicking on download button
@browser.download_path = File.dirname(filePath)
@browser.close
边缘代码:
@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: test_01_click_download_pass(Download_A_File): NoMethodError: undefined method `download_path=' for #<Selenium::WebDriver::EdgeHtml::Driver:0x0000000004cdd8a0>
环境详情:
OS: Windows 10
Programming Language: ruby (v2.5.5)
Gem : selenium-webdriver (v alpha4)
推荐答案
检查后selenium EdgeDriver 库 和 Microsoft Edge WebDriver 文档,好像没有办法通过selenium Edge webdriver设置更改下载文件路径.
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.
我建议您可以通过 Edge 设置直接更改 Edge 中的默认下载位置.此外,您还可以尝试通过更改注册表来更改 Edge 浏览器设置.更多详细信息,请查看以下链接:
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:
这篇关于使用 selenium 更改 Edge 的默认文件下载路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!