class:dialog
class: Dialog v0.9.0
Dialog 對(duì)象通過 'dialog' 事件的頁面分發(fā)。
一個(gè)使用 Dialog 類的例子:
const puppeteer = require('puppeteer');
puppeteer.launch().then(async browser = >{
const page = await browser.newPage();
page.on('dialog', async dialog = >{
console.log(dialog.message());
await dialog.dismiss();
await browser.close();
});
page.evaluate(() = >alert('1'));
});
Methods
- dialog.accept([promptText])v0.9.0
- dialog.defaultValue()v0.9.0
- dialog.dismiss()v0.9.0
- dialog.message()v0.9.0
- dialog.type()v0.9.0
Methods
dialog.accept([promptText])v0.9.0
- promptText <string> 提示中輸入的文本。 如果對(duì)話框的類型不提示,不會(huì)產(chǎn)生任何影響。
- returns: <Promise> Promise which resolves when the dialog has been accepted.
dialog.defaultValue()v0.9.0
- returns: <string> 如果對(duì)話框出現(xiàn)提示,則返回默認(rèn)提示值。 否則,返回空字符串。
dialog.dismiss()v0.9.0
- returns: <Promise> Promise which resolves when the dialog has been dismissed.
dialog.message()v0.9.0
- returns: <string> 顯示在對(duì)話框中的信息。
dialog.type()v0.9.0
- returns: <string> 對(duì)話框類型,可以是 alert ,beforeunload ,confirm 或 prompt 中的一個(gè)。
更多建議: