Skip to content

LinkedIn Login

This tutorial will teach you, who to automatize LinkedIn login. This tutorial could be used as base for other automation projects over LinkedIn.

Preparing Your Script

First of all we will create our automation struture under <MARVIN_HOME>\script folder.

As we gonna create this automation using computer vision, we'll create the assets folder, to save our template images.

linkedin\
    assets\
    script.mvn

On Windows Explorer, go to your <MARVIN_HOME>\script folder - usually on default installation MARVIN_HOME is setted to C:\Program Files\Marvin - and create a new folder named linkedin.

Windows Explorer

Automation Script

Open LinkedIn Page

Now we can start with our automation over LinkedIn.

First of all, let's open LinkedIn on Chrome browser. To do this, let's add this code inside our script.mvn file.

script.mvn
chrome.open('https://www.linkedin.com') # Open LinkedIn

Now let's start our automation, running the linkedin script. For further information on how to execute a script, refer to Running Scripts on Getting Started.

This script will open a new Incognito Chrome instance, and redirect automatically to LinkedIn Login screen.

LinkedIn Login

LinkedIn Login

Now, is time to automate LinkedIn login process.

First of all, let's take a look on LinkedIn login form:

LinkedIn Login Fields

We can identify 3 different key elements to work with:

  • Email or phone number field
  • Password field
  • Sign In button

For Tutorial purpose, we will mix two different ways to navigate over those 3 elements, Computer Vision and Keyboard.

Email or phone number Field:

To click on this field we will select Computer Vision, so we need to save a template from this field, name it as login-field.png, and save on assets folder

Bellow an example of the login-field.png template image:

Login Field as "login-field.png"

It's not necessary to get entire field for Marvin to understand where it should click on, just part of the field is enought for Marvin.

And as action we will user mouse.click_image. With this action Marvin will find the template on screen and click on its center.

Password Field:

For password field we will use keyboard navigation, pressing TAB key. As tab key is pressed, cursor will change from "Email or phone number" field to "Password" field, so we can type our password.

To press the TAB key we will use the action keyboard.press to indicate Marvin wich key should be pressed.

Sign In Button

For Sign In Button, we will use computer vision once more. So we need to get another template, now from the Sign In button, and save it on our assets folder, named as signin-button.png.

Bellow an exemple of the signin-button.png template image:

Sign In Button

Putting it all together

Now that we define all strategies to access fields, is time to put it all together.

Let's add some new lines to our script.mvn file.

script.mvn
1
2
3
4
5
6
7
chrome.open('https://www.linkedin.com')

mouse.click_image('login-field.png') # Click on "E-mail or phone number" field
keyboard.type_text('[email protected]') # Type user e-mail for login
keyboard.press('tab') # Press TAB button
keyboard.type_text('Password@2022') # Type user password
mouse.click_image('signin-button.png') # Click on "Sign In" button

Line 3: command to click on Email or phone number field, based on the image template

Line 4: as cursor is setted to correct field, Marvin will type text [email protected], as login

Line 5: to move cursor from login to password field, Marvin will press TAB key

Line 6: again Marvin will type a text, but this time Password@2022 as password

Line 7: Marvin will click on Sign In button, given as template

Running Script

Running this automation, now we can access LinkedIn on logged area, as shown on image bellow:

Logged to LinkedIn