简体   繁体   中英

How to download a file using Selenium Webdriver(JAVA) on the browserstack or GRID and check its Content?

When the file is downloaded it is usually saved in the local machine at the set downloaded location. So when we use browserstack/GRID, the file is downloaded in the browserstack/GRID local folders and the code in either running in our machine or JENKINS.

I am able to download a file in the respective local folders but not able to read the content or even not able to check whether the file has been downloaded or not. Whether we can download the file in our local machine or in JENKINS server (ie where the code is running).

Thanks in Advance.

I think you can use remote location(On which system you want file to be available) and set it in default download location to profile

Set Download location for FF: You need to set

profile.setPreference("browser.download.dir", "//myhostip/somecommonlocation/somedir");

Hope this helps. :)

I faced this same behavior when I needed to verify the contents of the downloaded file. On contacting BrowserStack support, I learned that one way to approach this would be to download the file on Remote BrowserStack Machine.

Once after the file gets downloaded onto the remote BrowserStack machine, then use the file path of the downloaded file and upload it to some public cloud like Google Drive, etc. and then download it to your local machine using the generated URL from the Drive.

I got the response as that Below are the default download paths for BrowserStack machines:

Win XP: C:\\Documents and Settings\\hello\\Downloads

Win 7 / 8 / 8.1 / 10: C:\\Users\\hello\\Downloads

Mac: /Users/test1/Downloads

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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