Reputation: 13
Problem with upload files.
I don't know why this can happen. Maybe not for every site. I don't know why this can happen. Maybe not for every site. I don't know why this can happen. Maybe not for every site.
if (config.executable_path === "" || config.executable_path === false) {
this.browser = await puppeteer.launch({
headless: config.chrome_headless,
args: config.chrome_options,
defaultViewport: {"width": 1024, "height": 768}
});
} else {
this.browser = await puppeteer.launch({
headless: config.chrome_headless,
args: config.chrome_options,
executablePath: config.executable_path,
defaultViewport: {"width": 1024, "height": 768}
});
}
bot = await this.browser.newPage();
bot.setViewport({"width": 1024, "height": 768});
let user_agent = await this.browser.userAgent();
bot.setUserAgent(user_agent.replace("Headless", ""));
await this.bot.emulate(iPhone);
let selector = "span[aria-label=\"New Post\"]";
await this.bot.waitForSelector(selector, {timeout: 5000});
await this.utils.sleep(this.utils.random_interval(3, 4));
var filePath = path.relative(process.cwd(), this.config.assets_path + photo);
const [fileChooser] = await Promise.all([
this.bot.waitForFileChooser(),
this.bot.click(selector),
]);
await fileChooser.accept([filePath]);
Error: File chooser handling does not work with multiple connections to the same page
Upvotes: 1
Views: 3257
Reputation: 189
it can be your browser that doesn't support the fileChooser, my old Chromium comes this error and chrome too, after upgrade to a Chromium 77.0.3844.0 (r674921) or higher. it works with puppeteer 2.1.0 very well
Upvotes: 1
Reputation: 11
As McD wrote try running in Chromium instead of Chrome. It seems there is an issue with chrome and file upload: https://github.com/GoogleChrome/puppeteer/issues/4783
Upvotes: 1
Reputation: 173
I solved this by running in Chromium. It should work if you remove the executablePath parameter from the config.
Upvotes: 1