Slake
Slake

Reputation: 2160

How to set values of DOM elements with puppeteer?

How to set specific values of the DOM with Puppeteer?

i.e:

b = document.querySelector("button");

Upvotes: 4

Views: 6084

Answers (1)

Slake
Slake

Reputation: 2160

For the innerHTML:

await page.evaluate(() => document.querySelector('button').innerHTML = 'value');

For the specific attribute:

await page.evaluate(() => document.querySelector('button').setAttribute('specific-attr', 'value'));

Upvotes: 7

Related Questions