Download a file to a specific path using Selenium WebDriver

前端 未结 3 1409
春和景丽
春和景丽 2021-01-15 13:54

I need to download a file to a given location on a non-local machine. This is the normal flow of the web browser for which I would do this:

  • Go to website
3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-15 14:57

    You would have to examine the javascript on the website and understand how it works before you could override it to do something like that, but even then, browser security will always pop a dialog asking you to confirm the download. That leaves you with two options (as far as I can see):

    • Confirm the alert dialog
    • Determine the location of the file on the remote server, and use a GET to download the file

    I can't really help with the details on either, since I don't know python, but hopefully that helps...

提交回复
热议问题