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

2.1.0 and 2.1.1 uploadFile failing #5420

Closed
Georgegriff opened this issue Feb 13, 2020 · 6 comments
Closed

2.1.0 and 2.1.1 uploadFile failing #5420

Georgegriff opened this issue Feb 13, 2020 · 6 comments

Comments

@Georgegriff
Copy link

I have this code: (via codeceptjs)

    async attachFile(locator, pathToFile) {
      const file = path.join(global.codecept_dir, pathToFile);

      if (!fileExists(file)) {
        throw new Error(`File at ${file} can not be found on local system`);
      }
      const els = await findFields.call(this, locator);
      assertElementExists(els, 'Field');
      await els[0].uploadFile(file);
      return this._waitForAction();
    }

In in 2.0.0 this works but in 2.1.0 and 2.1.1 this no longer works.

@Georgegriff Georgegriff reopened this Feb 14, 2020
Georgegriff referenced this issue Feb 14, 2020
…al (#5196)

* fix: prepare jsHandle.uploadFile for CDP Page.handleFileChooser removal

https://chromium-review.googlesource.com/c/chromium/src/+/1935410
removes Page.handleFileChooser from the CDP.

* fix: improve binary file support

UTF-8-decoding the input file could fail for binary files, and so we
now read the raw file buffer and base64-encode it. To base64-decode it
within the page context, we use the Fetch API in combination with a
data URL. This requires knowing the proper MIME type for the input
file, which we now figure out using the new mime-types dependency.
@gziolo
Copy link
Contributor

gziolo commented Feb 17, 2020

I can confirm that it works properly with 2.0.0 but it doesn't work with 2.1.1:
WordPress/gutenberg#20268 (comment)

@swftvsn
Copy link

swftvsn commented Feb 18, 2020

Same here, uploads fail with 2.1.1

@Georgegriff Georgegriff changed the title 2.1.0 uploadFile failing 2.1.0 and 2.1.1 uploadFile failing Feb 18, 2020
@yurynix
Copy link

yurynix commented Feb 24, 2020

This works for me as workaround on:
80.0.3987.0 puppeteer-core version: 2.1.1
79.0.3945.0 puppeteer-core version: 2.1.0

  const uploadInput = await page.$(someSelector)
  const filePath = path.join(__dirname, fileRelativePath);
  await uploadInput.uploadFile(filePath);
  await page.evaluate((inputSelector) => {
    document.querySelector(inputSelector).dispatchEvent(new Event('change', { bubbles: true }));
  }, someSelector)

So maybe something like #5446 is in order?

@DJ-Glock
Copy link

DJ-Glock commented Feb 26, 2020

Same issue. And workaround with uploadFile for input element does not work for our site, because we use custom inputs. Anyway it needs to be fixed.

@sfedorin
Copy link

sfedorin commented Apr 2, 2020

Hi everyone. Guys, is there any progress?

johnyb added a commit to open-xchange/appsuite-frontend that referenced this issue Apr 14, 2020
… to latest version. Living on the edge :)
Can't upgrade puppeteer for now, due to puppeteer/puppeteer#5420
It should be fixed with 2.1.2 release.
@paullewis
Copy link
Contributor

This should be fixed as of 532ae57 as we changed the underlying implementation to use DOM.setFileInputFiles, which behaves a lot more as expected. We also fire events for change and input, too. Going to close this issue, but please let us know if it's not fixed.

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.

7 participants