-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG][Electron] filechooser event not emitted when dialog.show(Open|Save)Dialog is called #8278
Comments
I'm also having trouble with showOpenDialogSync and showSaveDialogSync because the test stopped. |
I have create a test repo to trying to mock electron dialog like Does not work, but returned This Does anyone may have time to help to find out why? |
I am also having this issue and have been looking for a solution. @wsw0108 I am quite new to JS testing, but I will have a look into your code if I get some time. Please report back! |
@Daveiano I have found the fail cause, it's the async thing of electron ipc. The mock works actually. |
Based on spectron-fake-dialog, I wrote a little library to fake electron dialog for playwright/electron, |
Awesome! Can actually simplify this and just do: const electronApp = await playwright._electron.launch({ args: ['./main.js']});
// ...
// in test:
electronApp.evaluate(
async({ dialog }, filePaths) => {
dialog.showOpenDialog = () => Promise.resolve({ canceled: false, filePaths });
},
['file.txt']
); |
@MikeJerred Elegant solution. Can I use your idea to update my repo? |
Yep of course |
@wsw0108 I am getting this error when using playwright-fake-dialog
Setup is the following:
Any help and suggestions would be very appreciated! |
using 0.1.0 needs above lines in your electron main.js. If you use html input, just use filechooser from playwright. |
Ah, got you, thank you! I got it working now with the snippet from @MikeJerred, many thanks for that! |
H, i need some help to use the playwright-fake-dialog, do i need any code from "test/preload.js"?(https://github.com/wsw0108/electron-playwright-test/blob/master/test/preload.js). This is my code
And i get this ERROR in our Log-File: Our Application uses Electron 9, could that be a problem? |
best method, you can also control dialogs like so:
|
Investigation:
|
Playwright lacks support for interacting with native dialogs, so we mock the dialog module to simulate the user clicking the "Delete site" confirmation button with "Delete site files from my computer" checked. See: microsoft/playwright#2143 See: microsoft/playwright#8278 (comment)
Playwright lacks support for interacting with native dialogs, so we mock the dialog module to simulate the user clicking the "Delete site" confirmation button with "Delete site files from my computer" checked. See: microsoft/playwright#2143 See: microsoft/playwright#8278 (comment)
* test: Delete site E2E case supports native dialogs Playwright lacks support for interacting with native dialogs, so we mock the dialog module to simulate the user clicking the "Delete site" confirmation button with "Delete site files from my computer" checked. See: microsoft/playwright#2143 See: microsoft/playwright#8278 (comment) * test: Update Onboarding continue button label text * refactor: Fix typo * test: Improve stability of onboarding interactions Combine `toBeVisible`'s interval with the ability to assert the precence of one of multiple elements to ensure the UI is ready before conditionally proceeding with the onboarding steps. This reduces the likelihood that the UI is not ready when the test interactions begin and also allows the Sites tests to succeed regardless of whether sites already exists when the tests begin to run.
Hello everyone, do we have any updates on this ^^^? I am new to Playwright and I need help with a file upload in my Electron app. My app doesn't have an input element with type="file", so I have to use a FileChooser instead. Here's the scenario: there's a "Browse Files" button in the app. When I click it, a file manager dialog opens. I then select a file and click the "Upload" button in the file manager dialog to upload the file. In my script, it successfully clicks the "Browse Files" button, and the file manager dialog opens. However, it doesn't select a file or upload it, and the script times out with an error. Error: page.waitForEvent: Target page, context or browser has been closed Versions: Here is my test script:
I have tried this one as well:
Thank you all in advance!! |
Duplicate of #5013. Full details and repro steps available there.
Opening new issue as requested by maintainers on original issue.
This is definitely a blocker for our integration tests as we need to test open and save functionality in our app and we're not able to select the files in the dialogs.
The text was updated successfully, but these errors were encountered: