create_api_integration_test
Generate API integration test code for Robot Framework. Input base URL, endpoint, and method to receive .robot file content for testing REST APIs without execution.
Instructions
Generate Robot Framework API integration test code. Returns .robot file content as text - does not execute.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| base_url | Yes | ||
| endpoint | Yes | ||
| method | No | GET |
Implementation Reference
- mcp_server.py:991-1049 (handler)The handler function decorated with @mcp.tool(), implementing the create_api_integration_test tool. It validates the base_url, generates a Robot Framework template for API/UI integration testing using RequestsLibrary and SeleniumLibrary, substitutes variables, and returns the .robot file content.@mcp.tool() def create_api_integration_test(base_url: str, endpoint: str, method: str = "GET") -> str: """Generate Robot Framework API integration test code. Returns .robot file content as text - does not execute.""" try: validated_url = InputValidator.validate_url(base_url) template = Template("""*** Settings *** Library SeleniumLibrary Library RequestsLibrary Library Collections *** Variables *** $${BASE_URL} $base_url $${API_ENDPOINT} $endpoint $${BROWSER} Chrome *** Test Cases *** API UI Integration Test [Documentation] Test API and UI integration [Tags] integration api ui # API Setup and Validation Create Session api_session $${BASE_URL} $${api_response}= GET On Session api_session $${API_ENDPOINT} Status Should Be 200 $${api_response} $${response_data}= Set Variable $${api_response.json()} # UI Validation based on API data Open Browser $${BASE_URL} $${BROWSER} Maximize Browser Window # Validate UI reflects API data Wait Until Page Contains $${response_data['title']} 10s Page Should Contain $${response_data['description']} [Teardown] Run Keywords ... Close Browser AND ... Delete All Sessions *** Keywords *** Validate API Response Structure [Arguments] $${response} [Documentation] Validate API response has required fields Dictionary Should Contain Key $${response} id Dictionary Should Contain Key $${response} title Dictionary Should Contain Key $${response} description """) return template.substitute( base_url=validated_url, endpoint=endpoint, method=method.upper() ) except ValidationError as e: return f"# VALIDATION ERROR: {str(e)}\n# Please correct the input and try again." except Exception as e: return f"# UNEXPECTED ERROR: {str(e)}\n# Please contact support."