for example I have a variable called link , I want to get the value of that variable after exucuting a page.goto() in puppeteer .
this is example code
//this is my link variable
const link = "something";
(async() => {
const browser = await puppeteer.launch({
headless: false,
//args: ['--proxy-server=161.129.155.43:3128']
timeout: 20000
});
browser.userAgent(browsers[0]);
const page = await browser.newPage();
//called variable before goto()
console.log(link) //=>something
await page.goto(url);
//called variable after goto()
console.log(link) //=>undefined
await page.evaluate(() => {
setTimeout(() => {
document.getElementsByClassName("sA5rQ")[0].click();
}, 3000);
})
setTimeout(async() => {
await browser.close();
}, 60000);
})();
as you see in comments inside my code the value after executing page.goto() are undefined and I can only use variables from that page in browser by reading and scraping data .
how can I pass the link variable inside the pupputeer browser page?