uploadFile works not everytime.
See original GitHub issueI am trying to upload video to youporn.com with Puppeteer. My upload function looks like this:
async function uploadVideo(video, categories)
{
youPornPage.on('console', consoleObj => console.log(consoleObj.text()));
await youPornPage.setExtraHTTPHeaders({Referer: 'https://youporn.com'});
await youPornPage.goto('https://youporn.com/upload/', {
waitUntil: ['networkidle2']
});
await youPornPage.waitFor(20000);
let fileInput = await youPornPage.$(fileSelector);
await fileInput.uploadFile(BASE_PATH+'/Videos/'+video.filename);
await youPornPage.waitFor(3000);
let options2 = {
path: 'after.png',
fullPage: true
}
await youPornPage.screenshot(options2);
}
Browser configuration
puppeteer.launch({headless: true, args:['--no-sandbox', '--disable-setuid-sandbox'], ignoreHTTPSErrors: true, dumpio: false }).then(async browser => {
When I fill input file field with data, youporn then loads additional div where I can fill other information about video. The problem is, that this code works only once per 10-20 tries. I am sure that additional div is loaded when input file field’s change event is triggered. I tested and saw that uploadFile() function actually triggers that event, so I am guessing that there might be a problem with Javascript? Maybe some script is not loaded, but then I added 20sec waiting after page is loaded to make sure that javascript is loaded, and get the same results.
I tried to console log everything that I get when go to this webpage, and here are results:
Failed to load resource: the server responded with a status of 404 () Failed to load resource: net::ERR_UNKNOWN_URL_SCHEME Failed to load resource: net::ERR_UNKNOWN_URL_SCHEME Failed to load resource: net::ERR_UNKNOWN_URL_SCHEME Failed to load resource: net::ERR_UNKNOWN_URL_SCHEME Failed to load resource: net::ERR_UNKNOWN_URL_SCHEME Failed to load resource: net::ERR_UNKNOWN_URL_SCHEME ServiceWorker scope: https://www.youporn.com/ Expected version: 2e48ca520f95d921bc2d7049a7e7c18a0e58d661 The resource https://fs.ypncdn.com/cb/assets/fonts/gothic.woff2?v=2e48ca520f95d921bc2d7049a7e7c18a0e58d661 was preloaded using link preload but not used within a few seconds from the window’s load event. Please make sure it has an appropriate
as
value and it is preloaded intentionally. The resource https://fs.ypncdn.com/cb/assets/fonts/yp.woff2?v=2e48ca520f95d921bc2d7049a7e7c18a0e58d661 was preloaded using link preload but not used within a few seconds from the window’s load event. Please make sure it has an appropriateas
value and it is preloaded intentionally.
This is console log of the use case, when this code actually works correctly:
Failed to load resource: the server responded with a status of 404 () Failed to load resource: net::ERR_UNKNOWN_URL_SCHEME Failed to load resource: net::ERR_UNKNOWN_URL_SCHEME A preload for ‘https://fs.ypncdn.com/cb/assets/fonts/yp.woff2?v=2e48ca520f95d921bc2d7049a7e7c18a0e58d661’ is found, but is not used because the request credentials mode does not match. Consider taking a look at crossorigin attribute. Failed to load resource: net::ERR_FAILED ServiceWorker scope: https://www.youporn.com/ Expected version: 2e48ca520f95d921bc2d7049a7e7c18a0e58d661 The resource https://fs.ypncdn.com/cb/assets/fonts/gothic.woff2?v=2e48ca520f95d921bc2d7049a7e7c18a0e58d661 was preloaded using link preload but not used within a few seconds from the window’s load event. Please make sure it has an appropriate
as
value and it is preloaded intentionally. The resource https://fs.ypncdn.com/cb/assets/fonts/yp.woff2?v=2e48ca520f95d921bc2d7049a7e7c18a0e58d661 was preloaded using link preload but not used within a few seconds from the window’s load event. Please make sure it has an appropriateas
value and it is preloaded intentionally. Failed to load resource: net::ERR_UNKNOWN_URL_SCHEME
Only difference I see is additional
Failed to load resource: net::ERR_UNKNOWN_URL_SCHEME at the end.
Maybe someone could help me out, I am new to puppeteer, I guess that I missed some configuration but not sure where to look for. I have been trying to make this code consistent for two days.
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (4 by maintainers)
Top GitHub Comments
@dudeperfect95 a few things I noticed here:
page.$
I’d recommend usingpage.waitForSelector
- to await appearing ofinput
and thediv
you’re interested in.I can’t infer more from what I have; if you can share the whole script to play with I can check and see where and why it breaks.
@depsypher same here: if you can share your script so that I can play and debug it locally, it’d help a lot.
Since #3463 is closed, and since we updated
uploadFile
to be more as expected (as of 532ae573d29063ffd081ed9ee340d71b25320dec) I’m going to close this issue, but please let us know if it’s not fixed.