📌  相关文章
📜  获取元素文本 puppeteer - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:21.685000             🧑  作者: Mango

代码示例1
const puppeteer = require('puppeteer');

describe('My First Puppeteer Test', () => {
    it('should launch the browser', async function() {
        const browser = await puppeteer.launch({
             headless: false,
             slowMo: 50, 
             devtools: false,
        });
        const page = await browser.newPage();
        await page.goto('http://example.com/');
        const title = await page.title();
        const url = await page.url();
        const text = await page.$eval('h1', element => element.textContent)
        console.log('Text in the H1: ' + text);
        await browser.close();
    })
})