playwright-python icon indicating copy to clipboard operation
playwright-python copied to clipboard

[Bug]: can not download a file. when page to be close with alert

Open fr0zenrain opened this issue 2 months ago • 2 comments

Version

1.55

Steps to reproduce

<html>
<body>
<!--StartFragment-->
<script>
(function () {
for (var i = 1; i <= 4; i++) {
var input = 'input_' + i;
input = document.createElement("input")
input.type = "hidden"
input.value = Math.random()
document.body.appendChild(input)
}
})()
document.body.addEventListener('click', function () {
 
alert(" ");
window.location.href = 'test.exe';
 
});
 
</script>

<!--EndFragment-->
</body>
</html>

Expected behavior

download file and the subsequent logic will be executed normally

Actual behavior

download is going on, but the subsequent logic code not works.

Additional context

GPT tell me, after "alert" page was freed , the expect_download bind on the page .so it not works. GPT tell me there is a context.expect_download. and it's not exists.

Environment

- Operating System: [Ubuntu 22.04]
- CPU: [amd64]
- Browser: [All, Chromium]
- Python Version: [3.12]

fr0zenrain avatar Oct 20 '25 02:10 fr0zenrain

You can check the docs: https://playwright.dev/python/docs/downloads

Kempeter avatar Oct 20 '25 09:10 Kempeter

You can check the docs: https://playwright.dev/python/docs/downloads

GPT tell me that browser think "window.location.href" is a navigation, not a download. how to capture this download type bypass trick.thanks, what should we change browser driver or python sdk?

fr0zenrain avatar Oct 29 '25 01:10 fr0zenrain