DEV Community

Cover image for User Agent string difference in Puppeteer headless and headful

User Agent string difference in Puppeteer headless and headful

Sony AK on November 29, 2019

Today I will talk about the User Agent difference when we running Puppeteer in headless and headful mode. For people not familiar with Puppeteer, ...
Collapse
 
mnasirayub profile image
Muhammad Nasir Ayub

Hi everyone,
I am using Puppeteer library in NodeJS for runtime PDF file generation. It works fine on my local system, but when I deploy my app on a cPanel Based CentOs Os server, it throws an error. Any solution would be appreciated.

Collapse
 
omicron666 profile image
Omicron

There must be other altered behaviours too. Some tests were not working in headless mode, after developping them with browser display.

Collapse
 
sonyarianto profile image
Sony AK

ic ic, thanks for the info

Collapse
 
dynamitebud profile image
Rudra

Hi I wanted to know how to change the cdc variable to go undetected from the message of "chrome is controlled by an automation software". No idea if the site detected...

Collapse
 
sonyarianto profile image
Sony AK

Hi Rudra, thanks for the question. Actually I still have no idea about it as well. But any use case for you to hide that thing?

I found this link help.applitools.com/hc/en-us/artic... that maybe related to it?

Collapse
 
dynamitebud profile image
Rudra

Thank you.

Collapse
 
shakilsultan profile image
Shakil Sultan Ali

That's perfect dude! Thank you!

Collapse
 
mcdrecords profile image
M.C.D

Hello sir,
could you help me please?
I would like to load random useragent for each page lunch.
How do i do that?
Example:
page.setUserAgent('/utils/referers.txt');

thank you

Collapse
 
j2403sam profile image
Sam

I would have a variable called userAgents that is an array of user agent strings then do something like

await page.setUserAgent(userAgents[Math.floor(Math.random()*userAgents.length)]);

Collapse
 
mouhannadlrx profile image
Mouhannad

I logged in just to add like to this comment

Thread Thread
 
sonyarianto profile image
Sony AK

thank you :)

Collapse
 
martinratinaud profile image
Martin Ratinaud

Nice article, thanks