Setup & ApiServer Configuration
Playwright integration in Mbbrowser supports three languages. You can choose the one that aligns best with your team's expertise. Installation steps vary slightly for each; please read the relevant section.
Choose Your Language
TIP
- JavaScript (Node.js): Similar to Puppeteer; concise scripts. Recommended for frontend developers.
- Python: Ideal for data analysis or web scraping; Mbbrowser manages the virtual environment for you.
- Java: Seamless integration for enterprise projects or teams already using a Java stack.
1. JavaScript / TypeScript Environment
1. Install Node.js
Download the LTS Version (e.g., Node.js 20.x) from the Official Node.js Website.
Verify installation:
node -v # Should output v20.x.x or higher
npm -v2. Create Project and Install Playwright
# Create project folder
mkdir mb-playwright && cd mb-playwright
# Initialize npm project
npm init -y
# Install Playwright (Core library only; no need for built-in browsers, we use Mbbrowser)
npm install playwrightNOTE
During installation, Playwright may attempt to download browser files. Since we use Mbbrowser's browser, you can skip this by setting an environment variable:
set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
npm install playwright3. Install axios (For calling Mbbrowser ApiServer)
npm install axios2. Python Environment
1. Install Python
Download Python 3.8+ from the Official Python Website.
Make sure to check: ✅ Add Python to PATH during installation.
2. Mbbrowser Playwright Python Venv
IMPORTANT
Mbbrowser contains a built-in independent virtual environment for Playwright Python located at the python\Playwright\ subdirectory of your Mbbrowser installation path.
When running within the Mbbrowser Client's script manager, Mbbrowser activates this venv automatically.
If you wish to debug independently via the command line, manual activation is required:
# Navigate to the python directory in the Mbbrowser installation path
cd "C:\Program Files (x86)\Mbbrowser_vX.X.X\python"
# Activate the virtual environment
Playwright\Scripts\activate
# You can now use pip or run playwright commands normally3. Install Playwright Python Library
Once the virtual environment is activated:
pip install playwright requestsNOTE
playwright will install necessary dependencies but you do not need to run playwright install to download browsers.
3. Java Environment
1. Install JDK
Download JDK 11 or 17 (17 LTS recommended) from Adoptium.
2. Mbbrowser Playwright Java Driver
IMPORTANT
Mbbrowser bundles necessary JAR files for Playwright Java in its installation directory:
Mbbrowser_Installation_Path\
└── lib\
├── playwright-1.48.0.jar
├── driver-bundle-1.48.0.jar
└── gson-2.x.jarRunning Java scripts via the Mbbrowser script manager automatically extracts the driver-bundle and configures the environment.
3. Maven / Gradle Dependency
If using Maven:
<dependency>
<groupId>com.microsoft.playwright</groupId>
<artifactId>playwright</artifactId>
<version>1.50.0</version>
</dependency>4. Enable Mbbrowser ApiServer (All Languages)
IMPORTANT
Regardless of language choice, you must start the ApiServer before your script can communicate with Mbbrowser!
Get App Authentication Info
- Open Mbbrowser client and log in.
- Go to Personal Center → API Settings.
- Obtain (or generate) your
APP_IDandAPP_KEY.
Start ApiServer
Open CMD with administrator privileges and navigate to the Mbbrowser installation directory:
apiserver.exe --port=8186 --app_id=YOUR_APP_ID --app_key=YOUR_APP_KEY --hide=off| Parameter | Description | Recommended Value |
|---|---|---|
--port | Listening Port | 8186 (Default) |
--app_id | Authentication ID | From Personal Center |
--app_key | Authentication Key | From Personal Center |
--hide | Hide browser? | off (visible is better for debugging) |
Upon success:
ApiServer started at http://127.0.0.1:81865. Obtain Environment Session_ID
In the Mbbrowser main panel, find your target environment:
- Right-click → Copy Environment ID (Session_ID).
- Format: 32-character hex string (e.g.,
373808cb37bd63f5f7d92415e736e85f).
6. Understand ApiServer Response (ws field)
When calling /api/v1/browser/start, the returned data structure looks like this:
{
"code": 0,
"message": "success",
"data": {
"http": "127.0.0.1:9222",
"ws": "ws://127.0.0.1:9222/devtools/browser/YOUR-BROWSER-ID"
}
}| Field | Meaning | Usage in Playwright |
|---|---|---|
data.http | HTTP debugging address | Primarily for Selenium. |
data.ws | WebSocket CDP Address | Crucial for Playwright ✅ |
7. Setup Checklist
Before proceeding to the next chapter, ensure:
- [ ] Language runtime (JS/Python/Java) is installed.
- [ ]
playwrightlibrary is installed. - [ ] ApiServer is running and
http://127.0.0.1:8186/is accessible. - [ ] You have the
Session_IDfor your target environment. - [ ] You understand that
data.wsis the WebSocket address needed for Playwright.
TIP
Ready? The next chapter Quick Start: Connect provides complete, runnable scripts for all three languages.
