You could use the experimental Browser.setDownloadBehavior Chrome DevTools Protocol method.
Here is a full example:
Feature:
Background:
* def waitForDownload = function(downloadPath) { while (!new java.io.File(downloadPath).isFile()) java.lang.Thread.sleep(1000) }
Scenario:
* configure driver = { type: 'chrome' }
* driver 'https://github.com/karatelabs/karate/releases/tag/v1.3.0'
* driver.send({ method: 'Browser.setDownloadBehavior', params: { behavior: 'allow', downloadPath: karate.toAbsolutePath('./someDir') } })
# scroll to bottom of page to ensure download link is created
* script('let x = (document.scrollingElement || document.body); x.scrollTop = x.scrollHeight')
* waitFor("a[href='/karatelabs/karate/archive/refs/tags/v1.3.0.tar.gz']").click()
* call waitForDownload karate.toAbsolutePath('./someDir/karate-1.3.0.tar.gz')