Closed rffanlab closed 2 years ago
Same as Firefox.
I Debuged get into "setFileChooserInterceptedNoReply "
I change into Java got failed like this
Exception in thread "main" java.lang.NullPointerException: Cannot read field "isRemote" because the return value of "com.microsoft.playwright.impl.BrowserContextImpl.browser()" is null at com.microsoft.playwright.impl.Utils.addLargeFileUploadParams(Utils.java:168) at com.microsoft.playwright.impl.ElementHandleImpl.setInputFilesImpl(ElementHandleImpl.java:472) at com.microsoft.playwright.impl.FileChooserImpl.lambda$setFiles$0(FileChooserImpl.java:62) at com.microsoft.playwright.impl.LoggingSupport.lambda$withLogging$0(LoggingSupport.java:36) at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:47) at com.microsoft.playwright.impl.ChannelOwner.withLogging(ChannelOwner.java:85) at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:35) at com.microsoft.playwright.impl.FileChooserImpl.setFiles(FileChooserImpl.java:61) at com.microsoft.playwright.impl.FileChooserImpl.setFiles(FileChooserImpl.java:56) at com.microsoft.playwright.FileChooser.setFiles(FileChooser.java:80) at io.afu.autodeployweb.components.Test.main(Test.java:30)
from playwright.sync_api import sync_playwright, expect
import tempfile
with sync_playwright() as p:
with tempfile.TemporaryDirectory() as tmp_dir:
browser = p.chromium.launch_persistent_context(user_data_dir=tmp_dir, headless=False)
page = browser.new_page()
# https://playwright.dev/python/docs/api/class-filechooser
page.goto("https://pw.rwoll.dev/file-uploads")
with page.expect_file_chooser() as fc_info:
page.locator("#file-uploader").click()
file_chooser = fc_info.value
file_chooser.set_files("foo.txt")
expect(page.locator("body")).to_contain_text("Name: foo.txt, Size: 7")
page.pause() # pausing test so user can manually look for demo purposes
browser.close()
The above is working for me, assuming I have foo.txt
in the directory next to my script. Can you create a small repro by modifying the above showing it break in the same way you are seeing?
NB: self.page.on("filechooser", lambda file_chooser: file_chooser.set_files("/Users/fangluyu/tmp/Waves-70796.mp4"))
as the last line in your script looks like it would be flaky. You'll want to start listening for the event before you take the action that can trigger it.
My context:
Playwright Version: 1.25.2 Operating System: win10 Python version: 3.10 Browser: Chromium
In Safari and Firefox is working for me, but in Chromium it clicks to the input but it does not appear the filechooser and appears me this error: playwright._impl._api_types.TimeoutError: Timeout 30000.0ms exceeded while waiting for event "filechooser" E =========================== logs =========================== E waiting for event "filechooser" E ============================================================
Can you share a repro with us which we can run locally? Otherwise we can't act on it.
Context:
Code Snippet
Help us help you! Put down a short code snippet that illustrates your bug and that we can run and debug locally.
When start Using page.on("filechooser") it seems does not work for me. It failed to set file to filechooser