Skip to content

Setup & ApiServer Configuration

Before writing your first line of Selenium code, we need to prepare three things: the Python environment, the Selenium library, and the Mbbrowser ApiServer. This process takes approximately 10 minutes.


Step 1: Install Python

The Python bindings for Selenium require Python 3.8 or higher.

Download and Install

  1. Go to the Official Python Website and download 3.10 or 3.11 LTS version (recommended).
  2. During installation, make sure to check:
    Add Python to PATH (Failing to do this will cause errors for all subsequent commands!)
  3. Once installed, open Command Prompt (CMD) to verify:
bash
python --version   # Should output Python 3.10.x or higher
pip --version      # Should output pip version information

NOTE

If the python command doesn't work on Windows, manually add the Python installation directories (e.g., C:\Python310\ and C:\Python310\Scripts\) to the System Environment Variables → Path.


Step 2: Install Selenium Library

Run the following command in CMD or PowerShell:

bash
pip install selenium requests
  • selenium: The core automation library.
  • requests: Used to call the Mbbrowser ApiServer HTTP interfaces.

About ChromeDriver (Important!)

Selenium 4.6+ comes with Selenium Manager, which automatically downloads the ChromeDriver that matches your Mbbrowser kernel version.

However, since Mbbrowser uses a customized Chrome kernel, the version might differ from official Chrome. Follow these steps:

Method A (Recommended): Use the chromedriver included in the Mbbrowser installation directory

There is usually a chromedriver.exe in the Mbbrowser installation directory, with a path similar to:

C:\Program Files (x86)\Mbbrowser_vX.X.X\chromedriver.exe

Directly specify this path in your code (details in the next chapter).

Method B: Manual Download

  1. Log in to the Mbbrowser client, go to "Help → About," and record the kernel version (e.g., Chrome 140).
  2. Go to Chrome for Testing to download the same version of chromedriver.
  3. Place chromedriver.exe in your project directory or PATH.

Step 3: Enable Mbbrowser ApiServer

Mbbrowser exposes interfaces to external scripts via ApiServer.exe.

IMPORTANT

ApiServer must be enabled before the script can communicate with Mbbrowser! Do not close the ApiServer terminal window.

Get API Authentication Info

  1. Open the Mbbrowser client and ensure you are logged in.
  2. Navigate to the top-left menu → Personal CenterAPI Settings.
  3. Record your APP_ID and APP_KEY (if none, click "Generate").

Start ApiServer

Open CMD with administrator privileges, enter the Mbbrowser installation directory, and run:

bash
apiserver.exe --port=8186 --app_id=YOUR_APP_ID --app_key=YOUR_APP_KEY --hide=off

Parameter Description:

ParameterMeaningDefault Value
--portThe port ApiServer listens on8186
--app_idYour Authentication ID (from the personal center)-
--app_keyYour Authentication Key-
--hide=offoff means the browser window is visible (easy for debugging); on means headless modeoff

Upon successful startup, the CMD window will display:

ApiServer started at http://127.0.0.1:8186

Verify ApiServer Status

Visit http://127.0.0.1:8186/ in your browser or Postman. If you see the API documentation page, the startup was successful.


Step 4: Obtain environment Session_ID

Each Mbbrowser environment has a unique Session_ID, which is a 32-character hexadecimal string (e.g., 373808cb37bd63f5f7d92415e736e85f).

How to obtain it:

  1. Find the environment you want to operate in the Mbbrowser main panel.
  2. Right-click the environment and select Copy Environment ID (Session_ID).

We suggest creating a clear project folder on your computer:

my-mbbrowser-selenium/
├── start_selenium.py     ← Main Script
├── config.py             ← Config File (Store API_URL, SESSION_ID, etc.)
├── utils.py              ← Common utility functions (Start environment, screenshot, etc.)
└── requirements.txt      ← Dependency List

requirements.txt content:

selenium>=4.15.0
requests>=2.31.0

Other members can install dependencies simply via:

bash
pip install -r requirements.txt

Environment Setup Checklist

Before proceeding to the next chapter, ensure that:

  • [ ] Python 3.8+ is installed; python --version outputs correctly.
  • [ ] pip install selenium requests is complete.
  • [ ] You have located the chromedriver.exe path in the Mbbrowser directory.
  • [ ] ApiServer is started and http://127.0.0.1:8186/ is accessible.
  • [ ] You have obtained the Session_ID for the target environment.

TIP

All set? The next chapter Quick Start: Connect will lead you to write your first functional script!