Puppeteer: How to submit a form?

前端 未结 2 1203
离开以前
离开以前 2020-12-28 12:24

Using puppeteer, how could you programmatically submit a form? So far I\'ve been able to do this using page.click(\'.input[type=\"submit\"]\') if the form actua

2条回答
  •  情话喂你
    2020-12-28 13:11

    If you are attempting to fill out and submit a login form, you can use the following:

    await page.goto('https://www.example.com/login');
    
    await page.type('#username', 'username');
    await page.type('#password', 'password');
    
    await page.click('#submit');
    
    await page.waitForNavigation();
    
    console.log('New Page URL:', page.url());
    

提交回复
热议问题