microsoft / playwright-java

Java version of the Playwright testing and automation library
https://playwright.dev/java/
Apache License 2.0
1.16k stars 207 forks source link

[Question] Downloads temp file #269

Closed MacoGaminG closed 3 years ago

MacoGaminG commented 3 years ago

Hi, I'm making a program that will be able to bypass captchas. The problem is, I have to download the audio as a temporary file and then delete it.

I don't know how to do with playwright-java to download a file and put it in app directory with relative path.

(The audio is a web link like this: http://www.evidenceaudio.com/wp-content/uploads/2014/10/lyricslap.mp3)

Thanks.

yury-s commented 3 years ago

You could create a page with a download link and then use playwright to click on it, something like this:

    Download download = page.waitForDownload(() -> page.click("a"));
    System.out.println(download.path());