• Website
  • Server status
  • API documentation
  • Blog
Telegram Icon Community
EN
Русский
Português
English
中文 (中国)
Tiếng Việt
Sign in Start free
  • Website
  • Server status
  • API documentation
  • Blog
  • Community
  • English (US) Русский Português English 中文 (中国) Tiếng Việt
Log in View Plans

Custom Python scripts

Build powerful automation workflows with Python and the Multilogin API. Create, manage, and launch browser profiles with fully customizable scripts.

search icon

Try a different keyword or check for typos. If you still need help, contact support.

  • Getting started with Multilogin automation
  • Basic automation with CLI
  • Low-code automation with Postman
  • Script runner & predefined scripts
  • Puppeteer, Selenium, and Playwright
  • Custom Python scripts
  • Quick solutions with Developer Tools
  • External automation tools
  • Home
  • breadcrumb separator bar
  • Explore features
  • breadcrumb separator bar
  • Efficient task automation with API
  • breadcrumb separator bar
  • Custom Python scripts
  • breadcrumb separator bar
  • How to automate a login on a website

How to automate a login on a website

Written by Anton L ( Updated on August 26th, 2026 )

Updated on August 26th, 2026

This guide shows you how to automate a website login in a Multilogin browser profile using Python, Selenium, and the Multilogin API.

You will connect to Multilogin, start a browser profile, find the website’s login fields, enter credentials, and submit the login form.

This guide covers browser-profile website automation. For native Android app automation on cloud phones, use ADB or Appium instead.

This article is meant for creating your script step-by-step. If you want to use the full script for reference – feel free to scroll to the end.

 

Before you start, make sure you have:

  • Python and an IDE installed
  • requests and selenium modules installed
  • a Multilogin browser profile ready to use
  • your folder ID and profile ID
  • the Multilogin desktop app open, or the agent connected
  • access to automation on your plan

Step 1: prepare IDE or similar software

You'll need anything to write your script. It's up to you what to use, but we recommend to use IDE for that. Follow the first 4 steps from the following article: Getting started with automation scripting.

Step 2: create the script connecting to API and define functions

In this step, you'll need to make the script work with API. The script will include:

  • API endpoints
  • Variables for credentials
  • Defined functions for signing in, opening and closing profile
  • Imported modules, including requests, hashlib, time. Some modules related to Selenium will be included as well
  • Sign in request

Use the following template for it:

import requests
import hashlib
import time
from selenium import webdriver
from selenium.webdriver.chromium.options import ChromiumOptions
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.by import By

MLX_BASE = "https://api.multilogin.com"
MLX_LAUNCHER = "https://launcher.mlx.yt:45001/api/v1"
MLX_LAUNCHER_V2 = (
    "https://launcher.mlx.yt:45001/api/v2"  # recommended for launching profiles
)
LOCALHOST = "http://127.0.0.1"
HEADERS = {"Accept": "application/json", "Content-Type": "application/json"}
# TODO: Insert your account information in both variables below
USERNAME = ""
PASSWORD = ""
# TODO: Insert the Folder ID and the Profile ID below
FOLDER_ID = ""
PROFILE_ID = ""


def signin() -> str:
    payload = {
        "email": USERNAME,
        "password": hashlib.md5(PASSWORD.encode()).hexdigest(),
    }
    r = requests.post(f"{MLX_BASE}/user/signin", json=payload)
    if r.status_code != 200:
        print(f"\nError during login: {r.text}\n")
    else:
        response = r.json()["data"]
    token = response["token"]
    return token


def start_profile() -> webdriver:
    r = requests.get(
        f"{MLX_LAUNCHER_V2}/profile/f/{FOLDER_ID}/p/{PROFILE_ID}/start?automation_type=selenium",
        headers=HEADERS,
    )
    response = r.json()
    if r.status_code != 200:
        print(f"\nError while starting profile: {r.text}\n")
    else:
        print(f"\nProfile {PROFILE_ID} started.\n")
    selenium_port = response["data"]["port"]
    driver = webdriver.Remote(
        command_executor=f"{LOCALHOST}:{selenium_port}", options=ChromiumOptions()
    )
    # For Stealthfox profiles use: options=Options()
    # For Mimic profiles use: options=ChromiumOptions()
    return driver


def stop_profile() -> None:
    r = requests.get(f"{MLX_LAUNCHER}/profile/stop/p/{PROFILE_ID}", headers=HEADERS)
    if r.status_code != 200:
        print(f"\nError while stopping profile: {r.text}\n")
    else:
        print(f"\nProfile {PROFILE_ID} stopped.\n")

token = signin()
HEADERS.update({"Authorization": f"Bearer {token}"})

The template is similar to Selenium automation example, except it has the imported module below at the beginning. We import By from Selenium so the script can find the username field, password field, and login button on the page.

from selenium.webdriver.common.by import By

 

Step 3: choose web page to automate login process

You can use any website that contains login page. But for this guide, we recommend trying this page – it’s great for practicing automation tasks: Login Page.

Step 4: find the login form elements

In our case, it'll be the login fields and login button:

Zight 2025-12-04 at 14.46.35

We'll get all 3 elements on this page. Here's what you can do:

  1. Open DevTools in your browser. Here's how to do that for Chromium- and Firefox-based browsers:
    1. Windows and Linux: press Ctrl + Shift + I
    2. macOS: press Cmd + Option + I
  2. Make sure that you are on the “Elements” tab
  3. Use keyboard shortcut to find the element
    1. Windows and Linux: CTRL + F
    2. macOS: Cmd + F
  4. Look for the values you need to use for scraping. In our case, they will be the following: 
    1. id="username"for Username text field
    2. id="password" for Password text field
    3. class="radius" for Login button
  5. Select the elements with the tags in the “Elements” tab
  6. Click the selected value and copy the value of id or class attributes. For example, if you see id="username", you need to copy username
  7. Write down the values somewhere – you'll need it later
Zight 2025-12-04 at 15.19.28

Step 5: open the website in your script

  1. Get back to the IDE of your choice (for example, VS Code)
  2. Click the code field and add a variable for opening and performing actions in the profile: driver = start_profile()
  3. Add driver.get(“<your website>”). In our case, it'll be the following command: 
    driver.get("https://the-internet.herokuapp.com/login")
  4. Now we need some delay for the script, so it will try to do the other commands 5 seconds after opening the web page: time.sleep(5)

Step 6: find the login fields and button

Use this command to find the element: driver.find_element(By.<attribute on the page>, "<element>"). It tells the script exactly what to look for on the page. We copied several values for id and class attributes in our use case. Add the lines of code from the list below:

  1. Add the following string for username text field:
    driver.find_element(By.ID, "username")
  2. Add the following string for password text field:
    password = driver.find_element(By.ID, "password")
  3. Add the following string for login button:
    button = driver.find_element(By.CLASS_NAME, "radius")

We'll need to use those value later, so we need to make variables for the commands. You can name them any way you want, here are the examples:

login = driver.find_element(By.ID, "username")
password = driver.find_element(By.ID, "password")
button = driver.find_element(By.CLASS_NAME, "radius")

Step 7: enter the credentials and click Login

We told the script, what it should detect on the page. Now we are going to tell the script to add the credentials and log in the page. You'll use the following functions for that:

  • send_keys() to provide which symbols to type in the text fields
  • click() to imitate left mouse click

In our use case, you may have noticed, that the website has stated the following values for credentials:

  • tomsmith for the username
  • SuperSecretPassword! for the password

We need to tell the script to type those values and click the login button. Here are the strings of code:

login.send_keys("tomsmith")
password.send_keys("SuperSecretPassword!")
button.click()

Step 8: finish the script with the text notification

Our script is ready. You can proceed with preparations and run the script, but we recommend adding print() function, which will notify you about successful login. Think of the text for the function and add it at the end of script:

print("Signed in")

Add stop_profile() only if you want the browser profile to close after login. Leave it out if the next part of your automation needs to keep using the logged-in session.

 

Step 9: prepare the script before running it

  1. Install the following Python libraries (look for documentation of your IDE for more details):
    1. requests
    2. selenium
  2. Insert your values into the below variables in the script:
    1. USERNAME: your Multilogin account email
    2. PASSWORD: your Multilogin account password (MD5 encryption is not required)
    3. FOLDER_ID, PROFILE_ID: find these values using our guides on DevTools or Postman

Step 10: run the script

  1. Open the desktop app (or connect the agent if you are using the web interface)
  2. By default, the script below works for Mimic. To use it for Stealthfox, replace options=ChromiumOptions() with options=Options() in the following line:
    driver = webdriver.Remote(command_executor=f'{LOCALHOST}:{selenium_port}', options=ChromiumOptions())
  3. Run the .py file with your automation code 

In order to run the script in VS Code, сlick “Run” → “Run without debugging” (or “Start debugging”).

 

If you've done everything correctly, you'll be able to see the result in the terminal. You'll also notice a logged in account in the profile. 

AD scraper - US The Internet 2025-12-04 at 4.48.42 PM

Notes

Now you are good to go! You're not restricted to those only options. Python and Selenium are quite flexible tools, and there is more potential to them. Here are a couple of tips:

  • You can force the script to wait based on specific conditions (for example, the script will wait until a specific element appears on the page). You can read about it in the corresponding Selenium doc: Waiting Strategies
  • You can combine this and the script from the following article: Web scraping with Selenium 101. It will create a great starting point for your automation project!
  • There are more ways of implementing Selenium. Check their help center for more details: Selenium Documentation

Full script

import requests
import hashlib
import time
from selenium import webdriver
from selenium.webdriver.chromium.options import ChromiumOptions
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.by import By

MLX_BASE = "https://api.multilogin.com"
MLX_LAUNCHER = "https://launcher.mlx.yt:45001/api/v1"
MLX_LAUNCHER_V2 = (
    "https://launcher.mlx.yt:45001/api/v2"  # recommended for launching profiles
)
LOCALHOST = "http://127.0.0.1"
HEADERS = {"Accept": "application/json", "Content-Type": "application/json"}
# TODO: Insert your account information in both variables below
USERNAME = ""
PASSWORD = ""
# TODO: Insert the Folder ID and the Profile ID below
FOLDER_ID = ""
PROFILE_ID = ""


def signin() -> str:
    payload = {
        "email": USERNAME,
        "password": hashlib.md5(PASSWORD.encode()).hexdigest(),
    }
    r = requests.post(f"{MLX_BASE}/user/signin", json=payload)
    if r.status_code != 200:
        print(f"\nError during login: {r.text}\n")
    else:
        response = r.json()["data"]
    token = response["token"]
    return token


def start_profile() -> webdriver:
    r = requests.get(
        f"{MLX_LAUNCHER_V2}/profile/f/{FOLDER_ID}/p/{PROFILE_ID}/start?automation_type=selenium",
        headers=HEADERS,
    )
    response = r.json()
    if r.status_code != 200:
        print(f"\nError while starting profile: {r.text}\n")
    else:
        print(f"\nProfile {PROFILE_ID} started.\n")
    selenium_port = response["data"]["port"]
    driver = webdriver.Remote(
        command_executor=f"{LOCALHOST}:{selenium_port}", options=ChromiumOptions()
    )
    # For Stealthfox profiles use: options=Options()
    # For Mimic profiles use: options=ChromiumOptions()
    return driver


def stop_profile() -> None:
    r = requests.get(f"{MLX_LAUNCHER}/profile/stop/p/{PROFILE_ID}", headers=HEADERS)
    if r.status_code != 200:
        print(f"\nError while stopping profile: {r.text}\n")
    else:
        print(f"\nProfile {PROFILE_ID} stopped.\n")


token = signin()
HEADERS.update({"Authorization": f"Bearer {token}"})
driver = start_profile()
driver.get("https://the-internet.herokuapp.com/login")
time.sleep(5)
login = driver.find_element(By.ID, "username")
password = driver.find_element(By.ID, "password")
button = driver.find_element(By.CLASS_NAME, "radius")
login.send_keys("tomsmith")
password.send_keys("SuperSecretPassword!")
button.click()
print("Signed in")

This article includes third-party links that we don’t officially endorse.

 

Was this article helpful?

Give feedback about this article

In this article

  • Step 1: prepare IDE or similar software
  • Step 2: create the script connecting to API and define functions
  • Step 3: choose web page to automate login process
  • Step 4: find the login form elements
  • Step 5: open the website in your script
  • Step 6: find the login fields and button
  • Step 7: enter the credentials and click Login
  • Step 8: finish the script with the text notification
  • Step 9: prepare the script before running it
  • Step 10: run the script
  • Notes
  • Full script

Multilogin community

Stay informed, share your thoughts, and engage with others!

Telegram Icon Join us on Telegram

Read more on the topic

10 Best Datacenter Proxies for Web Scraping (2025 Edition) Apr 2, 2025 5 min read Google SERP Img

What is a Google SERP Proxy and Why Should You Care?

Apr 1, 2025 6 min read
UK Proxy Img

What Are Dedicated UK Proxies? Everything You Need to Know

Apr 1, 2025 6 min read
Related Article Title Icon

Related articles

  • How to set up Multilogin automation with Postman
  • How to navigate Multilogin API documentation with Postman
  • Getting started with automation scripting
  • Web scraping with Selenium 101

Mobile

  • Cloud phone
  • Virtual phone
  • Remote phone
  • Phone farming
  • Cloud cell phone
  • Cloud Android emulation
  • AI Quick Action Automation

Multi-accounting

  • Multiple Instagram accounts
  • Multiple Tiktok accounts
  • Multiple Reddit accounts
  • Multiple Telegram accounts
  • Multiple Facebook accounts
  • Multiple Youtube accounts
  • Multiple LinkedIn accounts

COMPARISON

  • Multilogin vs. MoreLogin
  • Multilogin vs. FlashID
  • Multilogin vs. DuoPlus
  • Multilogin vs. VMOS cloud
  • Multilogin vs. Octo Browser
  • Multilogin vs. AdsPower
  • Multilogin vs. GoLogin

Platform proxies

  • Mobile proxy
  • Reddit proxy
  • Instagram proxy
  • TikTok proxy
  • Facebook proxy
  • Youtube proxy
  • LinkedIn proxy

USECASES

  • Cloud phones for Tiktok
  • Cloud phones for Instagram
  • Cloud phones for Reddit
  • Cloud phones for Facebook
  • Cloud phones for Youtube

RESOURCES

  • Knowledge base
  • API documentation
  • Glossary
  • Academy
  • Blog
  • Server status
  • Release notes

FREE TOOLS

  • YouTube views to money calculator
  • Instagram money calculator
  • Online URL to text converter
  • Google local SERP checker
  • Random address generator

GET IN TOUCH

  • Contact 24/7 support
    support@multilogin.com
  • Referral program
  • Affiliate program
  • Pricing page
  • Careers
GDPR Compliant

© 2026 Multilogin. All rights reserved.

  • Privacy policy
  • Terms of service
  • Cookie policy
Multilogin watermark
  • MOBILE

    • Cloud phone
    • Virtual phone
    • Remote phone
    • Phone farming
    • Cloud cell phone
    • Cloud Android emulation
    • AI Quick Action Automation
  • MULTI-ACCOUNTING

    • Multiple Instagram accounts
    • Multiple Tiktok accounts
    • Multiple Reddit accounts
    • Multiple Telegram accounts
    • Multiple Facebook accounts
    • Multiple Youtube accounts
    • Multiple LinkedIn accounts
  • COMPARISON

    • Multilogin vs. MoreLogin
    • Multilogin vs. FlashID
    • Multilogin vs. DuoPlus
    • Multilogin vs. VMOS cloud
    • Multilogin vs. Octo Browser
    • Multilogin vs. AdsPower
    • Multilogin vs. GoLogin
  • PLATFORM PROXIES

    • Mobile proxy
    • Reddit proxy
    • Instagram proxy
    • TikTok proxy
    • Facebook proxy
    • Youtube proxy
    • LinkedIn proxy
  • USECASES

    • Cloud phones for Tiktok
    • Cloud phones for Instagram
    • Cloud phones for Reddit
    • Cloud phones for Facebook
    • Cloud phones for Youtube
  • RESOURCES

    • Knowledge base
    • API documentation
    • Glossary
    • Academy
    • Blog
    • Server status
    • Release notes
  • FREE TOOLS

    • YouTube views to money calculator
    • Instagram money calculator
    • Online URL to text converter
    • Google local SERP checker
    • Random address generator
  • GET IN TOUCH

    • Contact 24/7 support
      support@multilogin.com
    • Referral program
    • Affiliate program
    • Pricing page
    • Careers
GDPR Compliant
  • Privacy policy
  • Terms of service
  • Cookie policy

© 2026 Multilogin. All rights reserved.

Expand