Closed DNAScanner closed 2 years ago
Hello there, Can you upload some of your code? I might be able to see if your missing something... or you can try adding this with headless: false
mode:
browser.on('targetcreated', async target => { if (target.type() === 'page') { const page = await target.page() await page.target().createCDPSession() } })
This is my code. It worked until a few days
await new Pageres({delay: 3, script: `./web_scripts/google_translate/run.js`})
.source(translationUrl, ["1920x1080"], {filename: `${imageId}`, selector: `body > c-wiz:nth-of-type(1) > div:nth-of-type(1) > div:nth-of-type(2) > c-wiz:nth-of-type(1) > div:nth-of-type(2) > c-wiz:nth-of-type(1) > div:nth-of-type(1)`})
.destination("./images/")
.run();
You could try waiting for the selector to appear. Like set a timeout before continuing
Do you mean delay?
So no, you already have a delay of 3 seconds there... what im saying is have puppeteer wait for the selector maybe something like
page.waitForSelector('body
> c-wiz:nth-of-type(1) > div:nth-of-type(1) > div:nth-of-type(2) > c-wiz:nth-of-type(1) > div:nth-of-type(2) > c-wiz:nth-of-type(1) > div:nth-of-type(1)', {timeout: 10 * 1000})`
so instead of what your doing try something like this:
await new Pageres({
delay: 3,
beforeScreenshot: async (page, browser) => {
await checkSomething();
await page.waitForSelector('body > c-wiz:nth-of-type(1) > div:nth-of-type(1) > div:nth-of-type(2) > c-wiz:nth-of-type(1) > div:nth-of-type(2) > c-wiz:nth-of-type(1) > div:nth-of-type(1)', {timeout: 10 * 1000})
await page.click('do something with that selector or any other selector'); // you might not need this.
}
})
.source(translationUrl, ["1920x1080"],{filename: ${imageId}})
.destination('./images/')
.run();
console.log('finished so and so');
Plottwist, google just did some stuff i didnt like so that was the actual reason, why that stuff didn't work. Thanks anyways
Helo. First off, im not sure if this issue is from pageres or puppeteer itself, but I'm getting some weird error right after the pageres function has been called: