Automatically sign in with Google using Puppeteer

Let’s try to log in with Google to the website hosting this post

Marian Čaikovski
4 min readNov 3, 2021

Puppeteer is a tool imitating a user of a Chrome browser. You can easily program Puppeteer to automatically click buttons, fill fields or execute your JavaScript code on any website. Puppeteer has many use cases, but personally I use it mostly for automatic data import into web applications that have forms but do not support any quick ways of data import.

In this post I demonstrate how to automatically fill and submit the most common form — Sign in with Google.

Where could I log in with Google? Into any popular web site, including this one.

I try to sign in starting from a link https://medium.com/m/connect/google?state=google-%7Chttps%3A%2F%2Fmedium.com%2F that I found in the HTML of this website.

By default Puppeteer launches headless, or invisible, Chrome. The browser without graphical user interfaces is useful for applications running on servers. But developing Puppeteer-based code without seeing the page that is manipulated is needlessly complicated. So, during the quick development…

--

--

Marian Čaikovski

Java, JavaScript and SQL developer. Interested in data collection and visualization.