IBM Bob

image

IBM Bob

Bob is your AI development partner, built to augment your workflow and help you work confidently with codebases from design to deployment.


#AI

#IBMBob

 View Only

AI Automation Testing using Microsoft Playwright-mcp and IBM Bob in IBM Db2 Q replication

By Jasin C posted 19 days ago

  

Table of Contents

  1. Overview
  2. What is Playwright MCP and IBM Bob?
  3. Architecture: How they work together
  4. Selenium vs. Playwright — Feature comparison
  5. Setting up Playwright MCP with IBM Bob
  6. Test example
  7. Summary
  8. References

Overview

Playwright is an open-source, modern browser automation framework developed by Microsoft for testing and automating web applications. It enables developers and QA engineers to write reliable end-to-end (E2E) tests that simulate real user interactions across multiple browsers using a single API.

Unlike traditional automation frameworks, Playwright is designed to handle today's dynamic web applications, such as those built with React, Angular, Vue, and other JavaScript frameworks. It provides intelligent waiting mechanisms, robust element locators, built-in debugging tools, and cross-browser compatibility, making automated testing faster, more reliable, and easier to maintain. Playwright supports testing on Chromium (Google Chrome and Microsoft Edge), Mozilla Firefox, and WebKit (Safari), ensuring that applications behave consistently across different browsers and operating systems.

IBM Db2 Genius Hub (Db2GH) continues to evolve with agentic capabilities that transform database management into an AI-powered experience. As teams scale their Db2GH deployments, ensuring the reliability of its REST endpoints — particularly the QRep REST Central — through automated testing becomes critical.

This blog demonstrates how to use the Playwright Model Context Protocol (MCP) server together with IBM Bob (IBM's AI-powered developer assistant) to automate browser-based and API-level testing of Db2GH's QRep REST Central. We also provide a detailed comparison between Selenium WebDriver (legacy) and Playwright MCP (modern).


What is Playwright MCP and IBM Bob?

Playwright MCP server

The Playwright MCP (Model Context Protocol) server exposes Playwright's browser automation capabilities as a set of structured tools that any MCP-compatible AI client can call. Instead of writing test scripts manually, an AI agent can navigate pages, click elements, fill forms, capture screenshots, and assert page state — all through natural-language instructions that get translated into Playwright actions at runtime.

When Bob receives a test instruction, it internally coordinates three specialised agents to complete the work end to end:

Agent Role
Planner agent Analyses the target URL, reads the live accessibility tree via browser_snapshot, understands the page structure, and produces a step-by-step test plan — all before a single line of code is written.
Test generator agent Translates the planner's steps into concrete Playwright MCP tool calls (browser_navigate, browser_fill_form, browser_click, and so on) and executes them against the browser in real time.
Healer agent Monitors each step for failures (element not found, assertion mismatch, timeout). When a step fails, it re-reads the current accessibility tree, determines the correct selector or action, and re-executes the corrected step automatically — no human intervention required.

These three agents work in sequence for every test scenario, making the entire test lifecycle — planning, execution, and self-healing — autonomous.

Key Playwright MCP tools

Tool Description
browser_navigate Open a URL in a browser session
browser_snapshot Capture an accessibility tree snapshot of the current page
browser_click Click any element
browser_fill_form Fill multiple form fields at once
browser_network_requests Inspect REST API calls made by the page
browser_evaluate Run JavaScript to assert DOM state
browser_take_screenshot Capture visual proof of test results

IBM Bob

IBM Bob is an AI-powered developer assistant embedded in the IBM toolchain. Bob uses MCP servers — including the Playwright MCP server — as tools. Bob can be instructed in plain English to "test the Db2GH login page", and it will coordinate the Planner, Test Generator, and Healer agents to execute the full test and interpret the results.


Architecture: How they work together

The integration follows a three-layer model:

Test Developer
provides natural-language test instructions
prompt
↓
IBM Bob (AI agent)
Interprets intent → selects MCP tools → chains actions
MCP tool calls
↓
Playwright MCP server
browser_navigate / browser_click / browser_snapshot / ...
WebDriver protocol (CDP)
↓
Chromium / Firefox / WebKit (headless/headed)
Db2GH QRep REST Central (target UI)

Bob orchestrates all test steps — login, navigation, data entry, assertion — without any pre-written test script. The entire test specification lives in Bob's context as a prompt.


Selenium vs. Playwright — Feature comparison

The table below compares Selenium WebDriver and Playwright MCP feature by feature across every dimension relevant to modern test automation.

Feature Selenium Playwright MCP
Language / stack Java, Python, JavaScript, C#, Ruby JavaScript/TypeScript (first-class), Python, Java, C#
Browser driver Separate binary per browser — version must match browser Bundled patched binaries — no manual driver management
Browser support Chromium, Firefox, Edge, Safari, Opera Chromium, Firefox, WebKit (Safari engine)
Automation protocol W3C WebDriver standard Chrome DevTools Protocol (CDP) for Chromium; custom protocol for Firefox and WebKit
Selectors CSS, XPath, By.id, By.name, By.linkText, By.className CSS, XPath, role-based, text, label, test ID — ARIA-first
Locator creation Manual DOM/XPath inspection required; fragile when UI changes AI-assisted via MCP — Bob reads the live accessibility tree and derives locators automatically
Waiting strategy Manual WebDriverWait + ExpectedConditions on every interaction; Thread.sleep() workarounds common Built-in auto-wait — every click, fill, and check waits for the element to be visible, enabled, and stable
Network interception Not built-in; requires BrowserMob Proxy or browser DevTools extensions Built-in page.route() and page.on('request') — intercept, mock, or abort any request without a proxy
REST API assertion HAR capture via proxy; post-processing required; no inline assertion browser_network_requests — inspect status codes and payloads inline during the test
API testing Separate tool required (RestAssured, requests, etc.) Built-in APIRequestContext — browser and API tests in the same file
Screenshot Manual driver.getScreenshotAs() call required Captured automatically on failure; Bob can call it on demand
Video recording Not available Built-in per-test video recording; saved automatically on failure
Trace viewer Not available playwright show-trace — interactive HTML trace with timeline, DOM snapshots, network log, and console per step
Codegen Not available npx playwright codegen — records interactions and generates test code automatically
Headless execution Chromium and Firefox only; Safari headless not supported Full headless support for all three browsers
Browser contexts One isolated session per driver instance Lightweight browser contexts — multiple isolated sessions within one browser process
Multiple tabs / windows Requires switching WindowHandle manually Native multi-page support via context.newPage()
iframe support driver.switchTo().frame() — breaks locator context frameLocator() — interact with iframes using the same locator API as the main page
Mobile emulation Via Appium (separate framework) Built-in device descriptors with viewport, user-agent, and touch emulation
Parallel execution Requires Selenium Grid, TestNG/JUnit parallel config, or a cloud service Built-in parallel workers; each worker gets an isolated browser context — no external grid needed
AI / IBM Bob integration No MCP adapter; requires custom wrappers Native @playwright/mcp server — Bob issues Playwright actions directly from natural-language prompts
Test authoring Write test class manually; compile-and-run cycle Describe the test in plain English to Bob; Bob executes immediately — zero authoring overhead
Page objects Manual, convention-based classes AI-generated page objects derived from the live DOM snapshot via MCP
Debugging Manual log/screenshot/trace assembly Visual Trace Viewer with full timeline; Bob can re-run and diagnose failures autonomously
CI/CD Requires driver binaries pinned to browser versions; fragile on upgrades Official Docker image with all browsers pre-installed; no version pinning
Maintenance cost High — driver updates, selector fixes, and explicit waits accumulate Low — auto-wait, stable ARIA selectors, Bob can re-derive locators from the accessibility tree
Community maturity 20+ years; large ecosystem, broad language and framework coverage Growing rapidly; backed by Microsoft; TypeScript-first with strong IDE and documentation support
License Apache 2.0 Apache 2.0

Code comparison: Login to Db2GH for Q replication

The same login action expressed in both frameworks:

Selenium (Java) — legacy

// Selenium WebDriver — Db2GH login
WebDriver driver = new ChromeDriver();
driver.get("https://db2gh.example.com/login");

WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));

WebElement username = wait.until(
    ExpectedConditions.visibilityOfElementLocated(By.id("username"))
);
username.sendKeys("admin1");

WebElement password = driver.findElement(By.id("password"));
password.sendKeys("admin1_password");

driver.findElement(By.cssSelector("button[type='submit']")).click();

wait.until(ExpectedConditions.titleContains("Db2 Genius Hub"));
System.out.println("Login successful: " + driver.getTitle());
driver.quit();

Playwright MCP + IBM Bob — modern

Bob receives a natural-language instruction and issues Playwright MCP tool calls:

// Bob prompt:
// "Log into Db2 Genius Hub at https://db2gh.example.com with username admin1
//  and password admin1_password. Confirm the dashboard loads."

// Bob issues these Playwright MCP calls automatically:
browser_navigate({ url: "https://db2gh.example.com/login" })
browser_snapshot()   // ← Bob reads the page structure
browser_fill_form([
  { target: "#username", name: "Username", type: "textbox", value: "admin1" },
  { target: "#password", name: "Password", type: "textbox", value: "admin1_password" }
])
browser_click({ target: "button[type='submit']", element: "Submit" })
browser_wait_for({ text: "Dashboard" })
browser_take_screenshot({ type: "png", scale: "css" })

Setting up Playwright MCP with IBM Bob

Prerequisites

  • IBM Bob installed and licensed (version 1.5 or later)
  • Node.js 18+ installed on the workstation
  • Access to a running Db2 Genius Hub for testing purposes

Step 1: Install the Playwright MCP server

npm install -g @playwright/mcp@latest
npx playwright install chromium

Step 2: Register the MCP server in IBM Bob

Add the following entry to Bob's MCP server configuration file (~/.bob/mcp_servers.json):

{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": ["@playwright/mcp", "--headless"],
      "env": {}
    }
  }
}

For headed mode (visible browser window, useful for debugging):

{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": ["@playwright/mcp"],
      "env": {}
    }
  }
}

Alternatively, MCPs can be configured from the settings panel in IBM Bob.

Step 3: Verify the connection

Ask Bob to run a quick health check:

// Bob prompt:
"Navigate to https://db2gh.xxx.com and take a screenshot."

// Expected: Bob responds with a screenshot of the Db2GH login page.
Success indicator: If Bob returns a screenshot of the Db2GH login page or the dashboard, the Playwright MCP server is correctly connected.

Test example

Example: Login to Db2 Genius Hub (platform) for Q replication

This example walks through a full login test for Db2GH and shows exactly how the three Playwright MCP agents — Planner, Test Generator, and Healer — each play their part.

Bob prompt:
"Test the login page of Db2 Genius Hub at https://db2gh.example.com/login. Log in as Aadmin11234 / Aadmin1_password1234 and confirm the dashboard loads."

Step 1 — Planner agent: Analyse the page

The Planner agent opens the URL, captures the live accessibility tree, and produces a structured test plan before any test code is written.

// Planner agent — understand the page structure
browser_navigate({ url: "https://db2gh.example.com/login" })
browser_snapshot()
// ↳ Planner reads the accessibility tree and identifies:
//   - role="textbox" labelled "Username"  → selector: #username
//   - role="textbox" labelled "Password"  → selector: #password
//   - role="button"  name "Sign in"       → selector: button[type='submit']
//   - Success indicator: text "Dashboard" present after login

Planner output — test plan:

  1. Navigate to https://db2gh.example.com/login
  2. Fill Username field with "admin1"
  3. Fill Password field with "admin1_password"
  4. Click the Sign in button
  5. Assert the text "Dashboard" is visible on the resulting page
  6. Capture a screenshot as evidence

Step 2 — Test generator agent: Write and execute the test

The Test Generator agent translates each plan step into Playwright MCP tool calls and executes them against the live browser in sequence.

// Test generator agent — execute the plan
browser_fill_form([
  { target: "#username", name: "Username", type: "textbox", value: "admin1" },
  { target: "#password", name: "Password", type: "textbox", value: "admin1_password" }
])
browser_click({ target: "button[type='submit']", element: "Sign in" })
browser_wait_for({ text: "Dashboard" })
browser_take_screenshot({ type: "png", scale: "css",
                          filename: "login-success.png" })
// ✓ Dashboard text found — test passes

The agent will also write all possible test scenarios from the login page.

Step 3 — Healer agent: Detect and correct failures

Suppose a Db2GH UI update changed the submit button selector from button[type='submit'] to button[data-action='login']. The generated test would fail. The Healer agent intercepts the failure and fixes it automatically.

// Healer agent — triggered on step failure

// ✗ browser_click({ target: "button[type='submit']" }) → Element not found

// Healer re-reads the live accessibility tree
browser_snapshot()
// ↳ Healer finds: role="button" name="Sign in" → new selector: button[data-action='login']

// Healer retries with the corrected selector
browser_click({ target: "button[data-action='login']", element: "Sign in" })
browser_wait_for({ text: "Dashboard" })
browser_take_screenshot({ type: "png", scale: "css",
                          filename: "login-success-healed.png" })
// ✓ Step healed and test passes — no human intervention required

Healer report Bob surfaces:

⚠ Step 4 failed: selector "button[type='submit']" not found.
✔ Healer re-derived selector from accessibility tree: "button[data-action='login']"
✔ Step retried successfully. Test passed.
    Screenshot saved: login-success-healed.png

Summary

In this blog, we covered:

  • The architecture of Playwright MCP + IBM Bob as an AI-driven test automation platform for Db2 Genius Hub Qreplication.
  • The three-agent model — Planner, Test Generator, and Healer — that makes test authoring and self-healing autonomous
  • A comprehensive feature comparison between Selenium WebDriver and Playwright MCP across 27 dimensions
  • A concrete test example showing all three agents in action

By adopting Playwright MCP with IBM Bob,  teams eliminate the overhead of maintaining Selenium test infrastructure while gaining AI-assisted test authoring, built-in REST API assertion, and tighter integration with the IBM developer toolchain.


References

  1. Playwright documentation
  2. Playwright MCP server — GitHub
  3. IBM Db2 Genius Hub documentation
  4. Model Context Protocol (MCP) — Introduction
  5. Selenium WebDriver documentation

#community-stories1
0 comments
29 views

Permalink