optimistic-gold
optimistic-gold•3y ago

How to execute javascript code with Playwright?

How can I execute "document.execCommand("insertText", false, "25810") from playwright?
5 Replies
optimistic-gold
optimistic-goldOP•3y ago
this does now work page.evaluate("insertText", element);
optimistic-gold
optimistic-goldOP•3y ago
unfortunately it does now work 🙂 is page.evaluate() the same as document.execCommand? can I somehow access document in playwright instead of page?
Lukas Krivka
Lukas Krivka•3y ago
Yes, inside page.evaluate.
const html = await page.evaluate(() => {
return document.documentElement.innerHTML
})
const html = await page.evaluate(() => {
return document.documentElement.innerHTML
})
optimistic-gold
optimistic-goldOP•3y ago
thanks I found a solution now

Did you find this page helpful?