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
- Go to the Official Python Website and download 3.10 or 3.11 LTS version (recommended).
- During installation, make sure to check:
✅ Add Python to PATH (Failing to do this will cause errors for all subsequent commands!) - Once installed, open Command Prompt (CMD) to verify:
python --version # Should output Python 3.10.x or higher
pip --version # Should output pip version informationNOTE
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:
pip install selenium requestsselenium: 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.exeDirectly specify this path in your code (details in the next chapter).
Method B: Manual Download
- Log in to the Mbbrowser client, go to "Help → About," and record the kernel version (e.g., Chrome 140).
- Go to Chrome for Testing to download the same version of chromedriver.
- Place
chromedriver.exein 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
- Open the Mbbrowser client and ensure you are logged in.
- Navigate to the top-left menu → Personal Center → API Settings.
- Record your
APP_IDandAPP_KEY(if none, click "Generate").
Start ApiServer
Open CMD with administrator privileges, enter the Mbbrowser installation directory, and run:
apiserver.exe --port=8186 --app_id=YOUR_APP_ID --app_key=YOUR_APP_KEY --hide=offParameter Description:
| Parameter | Meaning | Default Value |
|---|---|---|
--port | The port ApiServer listens on | 8186 |
--app_id | Your Authentication ID (from the personal center) | - |
--app_key | Your Authentication Key | - |
--hide=off | off means the browser window is visible (easy for debugging); on means headless mode | off |
Upon successful startup, the CMD window will display:
ApiServer started at http://127.0.0.1:8186Verify 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:
- Find the environment you want to operate in the Mbbrowser main panel.
- Right-click the environment and select Copy Environment ID (Session_ID).
Step 5: Recommended Project Structure
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 Listrequirements.txt content:
selenium>=4.15.0
requests>=2.31.0Other members can install dependencies simply via:
pip install -r requirements.txtEnvironment Setup Checklist
Before proceeding to the next chapter, ensure that:
- [ ] Python 3.8+ is installed;
python --versionoutputs correctly. - [ ]
pip install selenium requestsis complete. - [ ] You have located the
chromedriver.exepath in the Mbbrowser directory. - [ ] ApiServer is started and
http://127.0.0.1:8186/is accessible. - [ ] You have obtained the
Session_IDfor the target environment.
TIP
All set? The next chapter Quick Start: Connect will lead you to write your first functional script!
