puppeteer:填写完表格后如何点击保存按钮?

puppeteer: How can the save button be clicked after the form is filled out?

表格填写后如何点击保存按钮?

<div class="MuiDialogActions-root MuiDialogActions-spacing">
   <button class="MuiButtonBase-root MuiButton-root MuiButton-outlined MuiButton-outlinedPrimary" tabindex="0" type="button">
     <span class="MuiButton-label">Cancel</span>
     <span class="MuiTouchRipple-root"></span>
  </button>
  <button class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary" tabindex="0" type="submit">
     <span class="MuiButton-label">Save</span>
     <span class="MuiTouchRipple-root"></span>
   </button>
</div>

我建议的解决方案是:

await page.waitForSelector('.MuiButton-label')
await page.click('.MuiButtonBase-label[name=save]')

但它不起作用。


如果您无法更改 HTML 那么我建议您这样做:

await page.click('button[type=submit]')