The Next Frontier: Model Context Protocol & TestFly
TestFly bridges modern AI coding assistants (Claude Desktop, Cursor, Copilot, Antigravity) through the testfly-mcp companion server.
1. Connecting testfly-mcp
Add to your mcp_config.json:
{
"mcpServers": {
"testfly-mcp": {
"command": "npx",
"args": ["-y", "testfly-mcp@latest"]
}
}
}
2. Generating TestFly Code from User Journeys
The AI launches a browser via MCP, records interactions, and writes clean TestFly code utilizing accessibility-first locators:
package io.testfly.examples;
import io.testfly.test.BaseTest;
import io.testfly.locator.Role;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
public class CheckoutFlowTest extends BaseTest {
@Test
public void userCompletesPurchase() {
open("/products");
getByRole(Role.BUTTON).withName("Add to Cart").click();
getByRole(Role.LINK, "Checkout").click();
getByLabel("Full Name").type("Hakan Gül");
getByRole(Role.BUTTON).withName("Place Order").click();
assertEquals(getByTestId("order-status").getText(), "CONFIRMED");
}
}
3. Self-Healing Locators (locators.selfHealing)
Enable locator self-healing in testfly.yml:
locators:
selfHealing: true
When an element is not found by its primary selector, TestFly's healing engine analyzes surrounding DOM attributes (accessible name, ARIA role, nearby text) to locate the element and keep your CI pipeline green.
Top comments (0)