PhantomJS screenshots not displaying text

I use PhantomJS to run some automated tests using Codeception. When I create a screenshot, however, the page is displayed, but no text is used, as an example below.

enter image description here

Here is the script I use to install phantomjs. I am using CentOS 7.1

echo "## Install phantomjs dependencies" sudo yum install freetype-devel fontconfig-devel libicu-devel gcc glib libpng-devel bison sqlite-devel gperf flex libjpeg-devel -y echo "## Install phantomjs" cd ~ PHANTOM_JS="phantomjs-2.1.1-linux-x86_64" wget https://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_JS.tar.bz2 sudo mv $PHANTOM_JS.tar.bz2 /usr/local/share/ cd /usr/local/share/ sudo tar xvjf $PHANTOM_JS.tar.bz2 sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/share/phantomjs sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin/phantomjs sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/bin/phantomjs sudo rm -fr $PHANTOM_JS.tar.bz2 phantomjs -v 

My initial thought was that I was missing a font library, but from what I can read on the phantomjs site I need to have all the packages.

+5
source share
2 answers

So my version of CentOS doesn't really have any fonts installed. Adding the following lines to my installation of the PhantomJS script added some fonts to the system, and the screenshots worked as expected.

 sudo yum install cabextract xorg-x11-font-utils -y sudo rpm -i https://downloads.sourceforge.net/project/mscorefonts2/rpms/msttcore-fonts-installer-2.6-1.noarch.rpm 
+8
source

If you don’t see the text in the screenshots after installing the fonts, make sure that you are using the correct user agent that reports what the OS your computer is running on. For instance:

 Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36 

- with this I can’t see the text.

 Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36 

- with this I see the text.

I am using Linux CentOS.

0
source

Source: https://habr.com/ru/post/1246267/


All Articles