New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Puppeteer is stripping £
from element content.
#1704
Comments
I wasn't able to duplicate that with this script: const p = require('puppeteer');
p.launch().then(async browser => {
for (let i = 0; i < 100; i++) {
const page = await browser.newPage();
await page.setContent(`<span itemprop="price" class="js-item-price">£20</span>`);
const element = await page.$('.js-item-price');
const text = await (await element.getProperty('textContent')).jsonValue();
console.log(text);
await page.close();
}
await browser.close();
}); |
Me neither. @jackfranklin |
AFAIK, the frontend developers is used to place price unit into <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.js-item-price::before {
content: "£"
}
</style>
</head>
<body>
<div class="js-item-price">20</div>
</body>
</html> So it is break away from html content, in this case, we cannot capture the price unit in div element's |
Thanks everybody for the investigation; if @indexmotion's suggestion is right, then this works as intended. |
Thanks everyone for taking the time to look into this; sorry I didn't reply sooner. We are updating the I'll keep doing some digging and report back if I find anything. |
Steps to reproduce
Tell us about your environment:
What steps will reproduce the problem?
Please include code that reproduces the issue.
We have some HTML that looks like so:
And we are accessing the contents of that element in Puppeteer with:
And sometimes (probably about 50% of the time), we get back the string "21". Other times we get back "£21" as expected.
I've tried a variety of ways to get at this value via the Puppeteer API, including also doing
page.$eval('.js-item-price', x => x.textContent)
but they have all had this problem.I'm not really sure if it's something I'm doing wrong in the test or a bug in Puppeteer but I wanted to report it in case anyone has any thoughts.
The text was updated successfully, but these errors were encountered: