Skip to main content
Glama

generate_java_page_object

Generate a Java Page Object and corresponding test class from a recorded browser session. Creates production‑ready code containing only the elements and actions actually performed, with support for TestNG, JUnit 5, or Selenium Boot.

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 raw Selenium (TestNG / JUnit 5) and the Selenium Boot framework (selenium_boot): Page Object extends BasePage, Test extends BaseTest, no manual driver lifecycle — the framework manages it — with accessibility-first locators. For any Java test in a Selenium Boot repo, use framework="selenium_boot".

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
frameworkNoOutput flavor: 'testng'/'junit5' emit standalone Selenium with a ChromeDriver setUp/tearDown; 'selenium_boot' emits Selenium Boot (BasePage/BaseTest, framework-managed driver, web-first assertions).testng
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
Behavior3/5

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

No annotations provided, so description must carry full burden. It discloses that output compiles as-is and never invents fields, and describes framework behavior. However, it does not mention if the tool is read-only, whether it modifies the recorded session, or any side effects. This is adequate but incomplete.

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

Conciseness4/5

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

Description is moderately long but well-organized: starts with main purpose, then benefits, then framework details. Every sentence adds value. Could be slightly more concise, but overall efficient.

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?

No output schema, so description must explain return values. It states clearly that two files are produced (Page Object and Test class) and gives details about their content (locators, fluent methods, framework-specific setup). It is complete enough for a generation tool, though it doesn't specify how the files are delivered (e.g., download, inline response).

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

Parameters4/5

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

Schema coverage is 100% with parameter descriptions. Description adds value by explaining the framework parameter in more detail and specifying the auto-stripping behavior for package_name (removing trailing '.pages' or '.tests'). This goes beyond schema.

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

Purpose4/5

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

Clearly states it generates Java Page Object and test classes from recorded sessions. Mentions producing two files and supported frameworks. However, doesn't explicitly differentiate from sibling Java generators like generate_java_testng or generate_java_junit5, which might cause confusion.

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?

Explicitly tells the agent to use this tool instead of writing Java manually, explains benefits (compiles as-is, no invented fields), and advises on framework selection based on project (Selenium Boot repos should use 'selenium_boot'). Lacks explicit when-not-to-use scenarios but is otherwise helpful.

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

Install Server

Other Tools

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/seleniumboot/selenium-mcp'

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