My challenge involves dynamically changing a string value that needs to be inserted into an input field.
(async () => {
let index = 1004327;
let browser = await puppeteer.launch({
headless: true,
});
let page = await browser.newPage();
while (1) {
await page.goto(`${link}${index}`);
page.setDefaultTimeout(0);
let html = await page.evaluate(async () => {
let data = document.getElementById(
"ctl00_phWorkZone_DbLabel8"
).innerText;
let object = {
information: data,
location: window.location.href,
};
return object;
});
if (Object.values(html)[0]) {
await staff.type(
"textarea[name=email]",
Object.values(html).join("\n"),
{
delay: 0,
}
);
console.log(index);
index++;
staff.click("input[name=save]", { delay: 0 });
}
}
})();
I have utilized the .type()
function, although it works, I am searching for a more efficient solution.