create_page_object_login
Generate Robot Framework page object model code for login pages. Provides .robot file content for web testing without execution, streamlining test automation setup with SeleniumLibrary.
Instructions
Generate Robot Framework page object model code for login page. Returns .robot file content as text - does not execute.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| template_type | No | appLocator |
Implementation Reference
- mcp_server.py:170-231 (handler)The core handler function for the 'create_page_object_login' tool, decorated with @mcp.tool() for registration in the MCP server. It generates a Robot Framework page object model for login functionality using configurable selectors based on the template_type parameter.@mcp.tool() def create_page_object_login(template_type: str = "appLocator") -> str: """Generate Robot Framework page object model code for login page. Returns .robot file content as text - does not execute.""" try: # Get selector configuration selectors = SELECTOR_CONFIGS.get(template_type.lower(), SELECTOR_CONFIGS["generic"]) # Use Template for safe variable substitution and correct Robot Framework syntax template = Template("""*** Settings *** Library SeleniumLibrary *** Variables *** # $template_type Application Selectors $${LOGIN_USERNAME_FIELD} $username_field $${LOGIN_PASSWORD_FIELD} $password_field $${LOGIN_BUTTON} $login_button $${LOGIN_ERROR_MESSAGE} $error_message *** Keywords *** Input Username [Arguments] $${username} [Documentation] Enter username in the username field Wait Until Element Is Visible $${LOGIN_USERNAME_FIELD} Clear Element Text $${LOGIN_USERNAME_FIELD} Input Text $${LOGIN_USERNAME_FIELD} $${username} Input Password [Arguments] $${password} [Documentation] Enter password in the password field Wait Until Element Is Visible $${LOGIN_PASSWORD_FIELD} Clear Element Text $${LOGIN_PASSWORD_FIELD} Input Text $${LOGIN_PASSWORD_FIELD} $${password} Click Login Button [Documentation] Click the login button Wait Until Element Is Enabled $${LOGIN_BUTTON} Click Button $${LOGIN_BUTTON} Login With Credentials [Arguments] $${username} $${password} [Documentation] Complete login process with given credentials Input Username $${username} Input Password $${password} Click Login Button Verify Error Message [Arguments] $${expected_message} [Documentation] Verify error message is displayed Wait Until Element Is Visible $${LOGIN_ERROR_MESSAGE} 10s Element Text Should Be $${LOGIN_ERROR_MESSAGE} $${expected_message} """) return template.substitute( template_type=template_type.upper(), username_field=selectors["username_field"], password_field=selectors["password_field"], login_button=selectors["login_button"], error_message=selectors["error_message"] ) except Exception as e: return f"# ERROR: {str(e)}\n# Please contact support."
- mcp_server.py:86-111 (helper)Predefined selector configurations for different application templates (appLocator, generic, bootstrap), directly used by the create_page_object_login tool to generate appropriate locators for login page elements.SELECTOR_CONFIGS = { "appLocator": { "username_field": "id=user-name", "password_field": "id=password", "login_button": "id=login-button", "success_indicator": "xpath=//span[@class='title']", "error_message": "xpath=//h3[@data-test='error']", "logout_button": "id=logout_sidebar_link" }, "generic": { "username_field": "id=username", "password_field": "id=password", "login_button": "css=button[type='submit']", "success_indicator": "css=.dashboard", "error_message": "css=.error", "logout_button": "css=.logout" }, "bootstrap": { "username_field": "css=input[name='username']", "password_field": "css=input[name='password']", "login_button": "css=.btn-primary", "success_indicator": "css=.navbar-brand", "error_message": "css=.alert-danger", "logout_button": "css=.btn-outline-secondary" } }