Skip to main content
Glama

generate_java_page_object

Generate a Java Page Object and matching test class from a recorded browser session, producing compilable code with only real actions and locators. Choose TestFly, TestNG, JUnit5, or Selenium boot output.

Instructions

Generate a Java Page Object class + matching test class from the recorded session. USE THIS INSTEAD OF WRITING JAVA BY HAND — the output compiles as-is and contains only the elements/actions actually performed, so it never invents fields or uses non-existent framework APIs. Produces two files: a Page Object (locators + fluent action methods) and a Test class that uses it. Supports TestFly (framework='testfly', default): Page Object extends BasePage, Test extends BaseTest, framework manages driver lifecycle, accessibility-first locators and web-first assertThat assertions. framework='testng'/'junit5' emit standalone raw Selenium.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
frameworkNoOutput flavor: 'testfly' (default) emits TestFly (BasePage/BaseTest, framework-managed driver, web-first assertions); 'testng'/'junit5' emit standalone Selenium with a ChromeDriver setUp/tearDown.testfly
page_nameNoName of the page class e.g. LoginPage. Auto-inferred from URL if omitted.
package_nameNoBase package, e.g. com.demo. The Page Object is placed in <base>.pages and the Test in <base>.tests. A trailing .pages or .tests is stripped, so passing either the base or a pages package works.com.example

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. First observedv1.0.0

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations present, the description carries the full burden, and it does substantial work: it discloses that output compiles as-is, includes only actually performed elements/actions, produces two files, and describes framework-specific behavior such as BasePage/BaseTest inheritance and raw Selenium output. It does not mention file overwriting or output delivery, but this is a strong disclosure for a generator tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is compact and front-loaded with the core purpose, then efficiently covers output guarantees, file structure, and framework variants. Every sentence adds useful information, and there is no filler or repetition of schema defaults.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a code-generation tool with no output schema and no annotations, the description is largely complete: it says what is generated, why it is safe, and how frameworks differ. The main missing piece is the behavior for the 'selenium_boot' enum value, which is a meaningful gap given the otherwise careful framework documentation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3, and the description does add flavor about framework internals (accessibility-first locators, web-first assertThat, BasePage/BaseTest). However, the framework enum includes 'selenium_boot', which is neither explained in the schema description nor in the tool description, leaving the agent unable to predict what that output flavor produces.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb ('Generate') and a concrete resource ('Java Page Object class + matching test class') sourced from the recorded session. It clearly distinguishes itself from test-only generators like generate_java_testng by promising both a Page Object and a test class, and by emphasizing that output compiles as-is and never invents fields or framework APIs.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly says 'USE THIS INSTEAD OF WRITING JAVA BY HAND' and explains the benefit: compiling output that only reflects performed actions. It gives clear framework-selection guidance for testfly vs testng/junit5, though it does not explicitly contrast this tool with sibling code-generation tools like generate_java_testng.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/hakanngul/testfly-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server