简体   繁体   English

如何在 node.js puppeteer 中输入表情符号?

[英]How to type emojis in node.js puppeteer?

How would I accomplish this?我将如何实现这一点? I'm looking to do something like我正在做类似的事情

const xpath = page.$x(‘thexpath’)

xpath[0].type(fireemoji)

and have the fire emoji show up on the page.并让火表情符号显示在页面上。 Is there an npm module for this?是否有一个 npm 模块?

You should be able to just copy and paste the emoji directly in there like so你应该能够像这样直接复制和粘贴表情符号

xpath[0].type(🔥);

if you look here puppeteer did have some emoji issues but it seems as if it was fixed in this release如果您看这里puppeteer 确实有一些表情符号问题,但似乎在此版本中已修复

so also make sure you have the most recent version of puppeteer installed所以还要确保你安装了最新版本的 puppeteer

this code is taken directly from a puppeteer unit test此代码直接取自 puppeteer 单元测试

await page.type('textarea', '👹 Tokyo street Japan 🇯🇵');

so make sure you are implementing .type() correctly所以确保你正确地实现了.type()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM