0

I am trying to upload a file using puppeteer and browserWSEndpoint, the error message I am getting is "Uncaught (in promise) Error: File chooser handling does not work with multiple connections to the same page". Here is my code:

  const puppeteer = require('puppeteer');

  async function getTest() {
    const browser = await puppeteer.connect({
      browserWSEndpoint: 'wss://chrome.browserless.io'
    });
    const page = (await browser.pages())[0];
    await page.goto('https://someWebSite');

    //DO STUFF

    console.log("before upload"); //code runs until here

    const [fileChooser] = await Promise.all([page.waitForFileChooser(),page.click('#uploadTrigger'),]); 
    await fileChooser.accept(['C:\\myProgram\\pic.jpg']);
    await page.click('#edit-submit');  
    }
    getTest().then(console.log);

I must mention that if I don't use browserWSEndpoint, and use this code at the beginning instead, everything works fine.

const browser = await puppeteer.launch({headless: false, defaultViewport:null});

Honnestly I am pretty lost with browserWSEndpoint, I used info from this post How to run Puppeteer code in any web browser? which led me to browserless.io, copied the code and it works.

Now this is my precise question, my error indicates does not work with multiple connections to the same page. How exactly am I connecting with multiple connections? Maybe I can resolve this issue and then I could use const [fileChooser]. My main issue is that I need to upload a file, using browserless

Others seem to have the same problem according to https://github.com/GoogleChrome/puppeteer/issues/4783, but using chromuim is not an option if I want to use browserless

hardkoded
  • 18,915
  • 3
  • 52
  • 64
JULIE_0420
  • 43
  • 4

1 Answers1

1

If you are the only client connected to that browser you must be connected to a browser that doesn't support the fileChooser. You should connect to a Chromium 77.0.3844.0 (r674921) or higher.

hardkoded
  • 18,915
  • 3
  • 52
  • 64