Contact Us
If you still have questions or prefer to get help directly from an agent, please submit a request.
Popular topics: Multilogin X, Multilogin 6,
-
Retrieving the token Using the automation token in a workspace Retrieving profile, folder, and workspace IDs Retrieving the user ID Selenium automation example Playwright automation example Puppeteer automation example Logging in to Multilogin automatically Setting up automatic cookie collection Auto-launching the agent Exporting proxy details from profiles Converting external proxy lists into API-ready JSON files Automation FAQConnecting the agent Testing a proxy Saving browser data Using a VPS/VPN to resolve connection issues Using Multilogin on macOS Investigating speed issues Can't start Multilogin Can't launch profile or connect to proxy Error: Failed to get profile data Stopping the agent from auto-sending log files Handling ban issues Issue: Profile is locked Troubleshooting FAQ
-
Error: Failed to get IP data: can't connect through proxy Error: Javax.crypto.badpaddingexception: pad block corrupted Status: Update in progress...Loading (1) of 2 components Error: Fingerprint composition failed Connection error due to non-Latin characters in Windows username Error: Mimic/Stealthfox executable is not found Multilogin 6 browser profile shows "Error" in status Can't launch a profile in Multilogin 6 JavaScript error when switching to dark mode in Multilogin 6 Common errors and solutions in Multilogin 6
Selenium automation example
Written by Jason Nguyen
Updated on December 12th, 2024
Table of contents
This simple automation script in Python uses the Selenium library to manipulate a profile in Multilogin X. It performs the following actions:
- Sign in using Multilogin X API
- Start the profile defining Selenium as the selected automation type
- Retrieve the port used by the running profile
- Start a Selenium driver on localhost using the retrieved port
- Use the driver to manipulate browser actions
- Stop the profile in 5 seconds
Before you start
- Install the following Python libraries:
- requests
- selenium
- Insert your values into the below variables in the script:
Running the script
- Make sure the agent is connected, as it makes profile launching possible
- By default, the script below works for Mimic. To use it for Stealthfox, replace
options=ChromiumOptions()
withoptions=Options()
in the following line:driver = webdriver.Remote(command_executor=f'{LOCALHOST}:{selenium_port}', options=ChromiumOptions())
- Run the
.py
file with your automation code
Script example
import requests
import hashlib
import time
from selenium import webdriver
from selenium.webdriver.chromium.options import ChromiumOptions
from selenium.webdriver.firefox.options import Options
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://multilogin.com/")
time.sleep(5)
stop_profile()