简体   繁体   English

如何使用selenium,java下载文件

[英]How to download a file using selenium, java

I need to download a file (the url is a mp3 file) using selenium webdriver, using chrome.我需要使用 selenium webdriver 下载一个文件(url 是一个 mp3 文件),使用 chrome。 When I get that URL, the mp3 starts playing without downloading, is there any way to download?当我得到那个 URL 时,mp3 开始播放而不下载,有没有办法下载? I need to download it through a proxy我需要通过代理下载

It could have been more helpful if you had provided the url.如果您提供了网址,可能会更有帮助。 I believe it would be something like: https://www.website.com/records/filename.mp3我相信它会是这样的: https : //www.website.com/records/filename.mp3

Remove the file name and reach the url: https://www.website.com/records/删除文件名并访问 url: https : //www.website.com/records/

Now there should be a webelement upon clicking which downloads the mp3.现在应该有一个点击下载mp3的webelement。 So you could perform a click action there.所以你可以在那里执行点击操作。

Edit: In the URL, which leads directly to playing mp3 file, there should be a context click(right click) option from where you can save the file.编辑:在直接导致播放 mp3 文件的 URL 中,应该有一个上下文单击(右键单击)选项,您可以在其中保存文件。 You could automate the same in Selenium using 'Actions' class, move arrow down and click on the option to save it.您可以使用“操作”类在 Selenium 中自动执行相同的操作,向下移动箭头并单击选项以保存它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM