简体   繁体   中英

How In geb download zip file into the current directory?

I try to use this function:

downloadBytes(exportLink.@href)

but I get array of bytes. How can I get zip file.

A file is nothing but an array of bytes. What do you need to actually do? You can save it somewhere by using a FileOutputStream, for example. You can use a ZipInputStream (with a ByteArrayInputStream) to read the entries directly in Java... So, what do you want to actually do?

I found another solution for saving zip in geb without asking directory. I configured my GebConfig.groovy :

    profile.setPreference("browser.download.folderList",2)
    profile.setPreference("browser.download.manager.showWhenStarting",false)
    profile.setPreference("browser.download.dir", new File("").getAbsolutePath())
    profile.setPreference("browser.helperApps.neverAsk.saveToDisk","application/zip") 

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