开发者

page.type: text: expected string, got undefined Playwright

I'm creating a generator that pulls a list of first and last names out of names.json and then puts them together with an email catchall and I'm getting the error page.type: text: expected string, got undefined using playwright. Whenever I console.log the variables it's logged exactly how it should be, but when it goes to type into the field I get expected string, got undefined. Does anyone have any ideas?



        const nameData = "names.json";
            function getNames() {
                if (fs.existsSync(nameData)) {
                    return JSON.parse(fs.readFileSync(nameData));
                }

        const names = {
            firstNames: prompt("Input Comma Separated Names:")?.split(/,\s*/) ?? [],
            lastNames: prompt("Input Comma Separated Names:")?.split(/,\s*/) ?? []
        };

            fs.writeFileSync(nameData, JSON.stringify(names));

            return names [Math.floor(Math.random() * names.length)];;
            }

            const { firstNames, lastNames } = getNames(); 


                let accountEmail = (`${firstNames[Math.floor(Math.random() *     firstNames.length)]}` + `${lastNames[Math.floor(Math.random() * lastNames.length)]}` + `@` + `${catchall}`);

                console.log('Loading Browser...');

        
        //------------------ Establishing Browser & Browser Properties ------------------//
    ( async () => {

        const browser = await firefox.launch({ 
            headless: false, // false = Shows Browser | true = Browser Not Shown
                proxy: {
                    server: `${proxyIP}`,
                    username: `${proxyUser}`,
                    password: `${proxyPass}`
            },
                ignoreHTTPSErrors: true,
                ignoreDefaultArgs: ['--enable-automation'],
                args: [
                        `--accept-lang`,
                        `--enable-auto-reload`,
                        `--disable-oobe-chromevox-hint-timer-for-testing`,
                        `--no-sandbox`,
                        `--disable-setuid-sandbox`,
                        `--incognito`,
                        `--disable-extensions`,
                        `--disable-site-isolation-trials`, 
                    ]
                });


    // Opens New Tab
        co开发者_高级运维nst context = await browser.newContext({
            userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36'
          });
        const page = await context.newPage();
        await page.goto('https://www.nike.com/', { timeout: 60000 } )
            console.log('Generating Cookies...');
        await page.screenshot({ path: `./log/homepage.png`});


    // Scroll To Bottom Function
        await page.evaluate(async () => {
            const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
            for (let i = 0; i < document.body.scrollHeight; i += 100) {
              window.scrollTo(0, i);
              await delay(100);
            }
          });


           //------------------ Registration Script ------------------//
        await page.goto('https://www.nike.com/login', { delay: 30000 });
          console.log('Navigating To Registration...')
           
        await page.type(`${firstNames[Math.floor(Math.random() * firstNames.length)]}` + `${lastNames[Math.floor(Math.random() * lastNames.length)]}` + `@` + `${catchall}`);
        await page.locator('name=firstName').click();```
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜