Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

get element text puppeteer

 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();
    })
})
Comment

puppeteer inner text

await page.waitForSelector('your selector')
let element = await page.$('your selector')
let value = await page.evaluate(el => el.textContent, element)
Comment

PREVIOUS NEXT
Code Example
Javascript :: js take last item in array 
Javascript :: react native network request failed fetch 
Javascript :: convert hsl to hex code javascript 
Javascript :: remove event listener react hooks 
Javascript :: node.js mysql create table 
Javascript :: jquery ajax google api 
Javascript :: react native set default ios simulator 
Javascript :: change value krajee star rating using jquery 
Javascript :: javascript match number 
Javascript :: create array initialize size javascript 
Javascript :: importing react 
Javascript :: extract filename from content-disposition header js 
Javascript :: rounded TouchableNativeFeedback 
Javascript :: use state value change right after setState or state update 
Javascript :: javascript go to page 
Javascript :: how to check if element is in viewport 
Javascript :: settimestamp discord.js 
Javascript :: JavaScript the last word of a string 
Javascript :: simulate a user click 
Javascript :: javascript find unique values in array 
Javascript :: how to access variables from render() to outside of render() in class react component 
Javascript :: scroll to bottom of an element 
Javascript :: set value using javascript 
Javascript :: javascript onclick display none 
Javascript :: loopback model properties 
Javascript :: javascript ascii to hex 
Javascript :: node express js set server timeout 
Javascript :: getelementbytagname javascript 
Javascript :: replace non alphanumeric javascript 
Javascript :: how to take an element out of an array in javascript 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =