Codementor Events

How I learned Chrome Headless / Puppeteer

Published Jul 01, 2018
How I learned Chrome Headless / Puppeteer

About me

Hi all. I'm Matías Sklar, I'm 41 years old and I'm from Argentina.
I'm a backend developer specializated on automated process.
My strength is build process that must hangle a high volume of data.
I'm looking for new freelance projects to be involved and bring my experience in differents scenarios

Why I wanted to learn Chrome Headless / Puppeteer

The reason for learn Chrome Headless / Puppeteer was to have some automated testing of the navigation of certain site.
In the company I work this days, we had some previous version of this test made with PhantomJs, but that project is deprecated at this moment and we take knowledge that some of its developers moving to Chrome Headless.
After some initial test we decided that this was a necessary change to do.

How I approached learning Chrome Headless / Puppeteer

The learning process was a team work. My team is formed by another PHP Senior Developer and my self.
With the decision of moving to Chrome Headless, we start to investigate differents ways to use this tool.
There are mainly two options to work with this: Selenium + ChromeDriver or Puppeteer.
We did our first test with Puppeteer than can install like a node.js module and we notes that was easy to navigate the site we need to test.
I had never developed any project with node.js before, so I had to learn about the "await" and "Promise" concepts, but as I participated of the previous Phantomjs project of our company that was not a serious problem.

Challenges I faced

The first challenge was to learn about the node.js structure.
Fortunately there are a lot of documentation and examples of simple scripts and we could to move forward quickly.
The conexion of the await and promises is the big concepts we need to understand.
The other challenge is to catch all the timeouts correctly when some network problem occur or when some element of the site we must test is not there.
And finally for now is be aware of the opening of new tabs on the chrome browser when you click some link.
I must lean how is the best way to debugging this things. Some times to read the "exception message" is enough. In other times I write the complete HTML of the page on a file log. And many times I take a screenshot to be sure that the browser is navigating the page I thought.

Key takeaways

The keys of this projects are:
1.- Don't be afraid if the tecnology you use is deprecated (Phantomjs), you always can find a new tecnology to replace it (or you can build your own!!)
2.- The good team work is the key something to accelerate the learning process
3.- If you need to choose between 2 options to learn, you must consider the documentation you could find
4.- I'm a developer. The tecnology challenges are the things I like to do.

Tips and advice

It was a good and successful experience because we start something with zero prevoius knowledge and we could build a good process to complete the task we were assigned.
I'm happy to be involved in this project.

Final thoughts and next steps

The next steps to do in this project is to build some control panel with better alerts.
To do this, I must integrate my robot with a lot of other process through multiples API's or other batch process.

See you on next post!!

Discover and read more posts from Matías Emanuel Sklar
get started
post commentsBe the first to share your opinion
Show more replies