Skip to content
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] Error uploading a file without an input[type="file"] element #5403

Closed
garciallorente-fer opened this issue Feb 10, 2021 · 0 comments · Fixed by #5467
Closed

[BUG] Error uploading a file without an input[type="file"] element #5403

garciallorente-fer opened this issue Feb 10, 2021 · 0 comments · Fixed by #5467

Comments

@garciallorente-fer
Copy link
Contributor

garciallorente-fer commented Feb 10, 2021

Context:

  • Playwright Version: 1.8.0
  • Operating System: Windows 10 Pro
  • Node.js version: 14.15.3
  • Browser: Chromium
  • Extra: Private WebPage

jest-playwright-preset

Code Snippet

const [fileChooser] = await Promise.all([
  page.waitForEvent('filechooser'),
  page.click('button[type=button]')
])
await fileChooser.setFiles('./src/uploads/uploadFile.xlsx')

Describe the bug

elementHandle.setInputFiles: Element is not attached to the DOM

      at Connection.sendMessageToServer (node_modules/playwright/lib/client/connection.js:69:15)
      at Proxy.<anonymous> (node_modules/playwright/lib/client/channelOwner.js:44:61)
      at node_modules/playwright/lib/client/elementHandle.js:151:40
      at ElementHandle._wrapApiCall (node_modules/playwright/lib/client/channelOwner.js:72:28)

Code Snippet

page.on('filechooser', async () => {
         const fileElement= await page.waitForSelector('[type="file"]', { state: 'attached' })
         await fileElement.setInputFiles('./src/uploads/uploadFile.xlsx')
 })
await page.click('button[type=button]')

Describe the bug

(node:19876) UnhandledPromiseRejectionWarning: page.waitForSelector: Protocol error (Runtime.callFunctionOn): Target closed.
=========================== logs ===========================
waiting for selector "[type="file"]"
============================================================

**
The webpage that I am trying to automate and use their upload document functionality has a button[type=button] that triggers a FileChooser Dialog, but there is no input[type=file] in the webPage, not even when opening the FileChooser after clicking that button (It doesn't seem to be created dynamically) as the element is not found at any stages of the automation.

I also tried to look for an element [type="file"] before and after opening the FileChooser and it doesn't find any.
**

@garciallorente-fer garciallorente-fer changed the title [BUG] Upload a File without an input[type="file"] element [BUG] Error uploading a file without an input[type="file"] element Feb 10, 2021
aslushnikov added a commit to aslushnikov/playwright that referenced this issue Feb 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant