FitLayout / fitlayout-puppeteer

Puppeteer-based web page renderer for FitLayout
0 stars 2 forks source link

Script index.js does not return whole texts on CZC.cz #2

Open SuperMartas opened 2 years ago

SuperMartas commented 2 years ago

Consider this command:

node index.js -W1920 -H1080 -P1 -s https://www.czc.cz/pocitace/produkty

I've been experiencing issues with not returning of whole texts for some products names and gifts. For example, I expect that product "Apple iMac 24" 4,5K Retina M1/8GB/256GB/7-core GPU, modrá" returns two boxes with texts "Apple iMac 24" 4,5K Retina" and "M1/8GB/256GB/7-core GPU, modrá". But what is actually returned is one box with only partial text "Mac 24" 4,5K Retina M1/8GB/256GB/7-core GPU, modrá".

This happens with more texts including text "Servisní pohotovost – vylepšený servis PC a NTB ZDARMA" and some more product names. Surprisingly, this does not happen on https://layout.fit.vutbr.cz/browser/#/ where it works as expected.

Testing environment:

If I have more info, I'll update this issue.

SuperMartas commented 2 years ago

I probably found out what is causing the issue. It is this cookie popup image in combination with document.caretRangeFromPoint https://github.com/FitLayout/fitlayout-puppeteer/blob/30cbb3a7fb41e68fb72819c6f26270ecb2ff3cb8/index.js#L722 which incorrectly returns range for some elements from the cookie popup instead of the correct range for the Apple product as seen in this image image

When I use custom Chrome profile (by using -d and -N arguments) where I have already accepted the cookies (so the cookie popup does not show up), the issue is completely gone. This might explain why it works on https://layout.fit.vutbr.cz/browser/#/ as there is no cookie popup for some (unknown) reason.

SuperMartas commented 2 years ago

There is a similar issue on https://www.mall.cz/pracky, see this image: image

However, this issue might possibly be caused by fixed height of element and overflow: hidden. It looks like this when not using screenshot: image