Skip to main content
Glama
sourcefuse

Robot Framework MCP Server

by sourcefuse

create_extended_selenium_keywords

Generate extended Robot Framework keywords for screenshots, performance monitoring, and window management in Selenium test automation.

Instructions

Generate extended Robot Framework keywords for screenshots, performance monitoring, and window management. Returns .robot file content as text - does not execute.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function for the 'create_extended_selenium_keywords' tool. Decorated with @mcp.tool() for registration in FastMCP. Generates comprehensive Robot Framework keyword library for advanced Selenium operations including screenshots, window management, performance monitoring, and more. No input parameters; returns Robot Framework code as string.
    @mcp.tool()
    def create_extended_selenium_keywords() -> str:
        """Generate extended Robot Framework keywords for screenshots, performance monitoring, and window management. Returns .robot file content as text - does not execute."""
        return """*** Settings ***
    Library    SeleniumLibrary
    Library    Collections
    Library    String
    Library    DateTime
    
    *** Keywords ***
    # Screenshot Capabilities
    Capture Full Page Screenshot
        [Arguments]    ${filename}=page_screenshot.png
        [Documentation]    Capture screenshot of entire page
        Capture Page Screenshot    ${filename}
        Log    Screenshot saved as: ${filename}
    
    Capture Element Screenshot
        [Arguments]    ${locator}    ${filename}=element_screenshot.png
        [Documentation]    Capture screenshot of specific element
        Wait Until Element Is Visible    ${locator}    10s
        Capture Element Screenshot    ${locator}    ${filename}
        Log    Element screenshot saved as: ${filename}
    
    Capture Screenshot With Timestamp
        [Documentation]    Capture screenshot with current timestamp in filename
        ${timestamp}=    Get Current Date    result_format=%Y%m%d_%H%M%S
        ${filename}=    Set Variable    screenshot_${timestamp}.png
        Capture Page Screenshot    ${filename}
        RETURN    ${filename}
    
    Set Screenshot Directory
        [Arguments]    ${directory_path}
        [Documentation]    Set custom directory for screenshots
        Set Screenshot Directory    ${directory_path}
        Log    Screenshot directory set to: ${directory_path}
    
    # Text Retrieval Operations
    Get Element Text Value
        [Arguments]    ${locator}
        [Documentation]    Get text content from an element
        Wait Until Element Is Visible    ${locator}    10s
        ${text}=    Get Text    ${locator}
        RETURN    ${text}
    
    Get Input Field Value
        [Arguments]    ${locator}
        [Documentation]    Get value from input field
        Wait Until Element Is Visible    ${locator}    10s
        ${value}=    Get Value    ${locator}
        RETURN    ${value}
    Switch To Window By Title
        [Documentation]    Switch to browser window by title
        [Arguments]    ${expected_title}
        @{windows}=    Get Window Handles
        FOR    ${window}    IN    @{windows}
            Switch Window    ${window}
            ${title}=    Get Title
            IF    '${title}' == '${expected_title}'
                RETURN
            END
        END
        Fail    Window with title '${expected_title}' not found
    
    Switch To Window By URL
        [Documentation]    Switch to browser window by URL pattern
        [Arguments]    ${url_pattern}
        @{windows}=    Get Window Handles
        FOR    ${window}    IN    @{windows}
            Switch Window    ${window}
            ${current_url}=    Get Location
            IF    '${url_pattern}' in '${current_url}'
                RETURN
            END
        END
        Fail    Window with URL pattern '${url_pattern}' not found
    
    Close Other Windows
        [Documentation]    Close all windows except the current one
        ${main_window}=    Get Window Handles
        ${main_window}=    Get From List    ${main_window}    0
        @{all_windows}=    Get Window Handles
        FOR    ${window}    IN    @{all_windows}
            IF    '${window}' != '${main_window}'
                Switch Window    ${window}
                Close Window
            END
        END
        Switch Window    ${main_window}
    
    Get Page Performance Metrics
        [Documentation]    Get basic page performance metrics using JavaScript
        ${load_time}=    Execute Javascript    return window.performance.timing.loadEventEnd - window.performance.timing.navigationStart
        ${dom_ready}=    Execute Javascript    return window.performance.timing.domContentLoadedEventEnd - window.performance.timing.navigationStart
        ${metrics}=    Create Dictionary    load_time=${load_time}    dom_ready=${dom_ready}
        [Return]    ${metrics}
    
    Scroll To Element Smoothly
        [Documentation]    Scroll to element with smooth animation
        [Arguments]    ${locator}
        Execute Javascript    
        ...    var element = document.evaluate("${locator}", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
        ...    if (element) { element.scrollIntoView({behavior: 'smooth', block: 'center'}); }
    
    Check Element Visibility Percentage
        [Documentation]    Check what percentage of element is visible in viewport
        [Arguments]    ${locator}
        ${visibility}=    Execute Javascript    
        ...    var element = document.evaluate("${locator}", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
        ...    if (!element) return 0;
        ...    var rect = element.getBoundingClientRect();
        ...    var viewport = {width: window.innerWidth, height: window.innerHeight};
        ...    var visible = Math.max(0, Math.min(rect.right, viewport.width) - Math.max(rect.left, 0)) *
        ...               Math.max(0, Math.min(rect.bottom, viewport.height) - Math.max(rect.top, 0));
        ...    var total = rect.width * rect.height;
        ...    return total > 0 ? (visible / total * 100).toFixed(2) : 0;
        [Return]    ${visibility}
    
    Take Element Screenshot
        [Documentation]    Take screenshot of specific element
        [Arguments]    ${locator}    ${filename}=element_screenshot.png
        Capture Element Screenshot    ${locator}    ${filename}
        [Return]    ${filename}
    
    Get All List Labels
        [Arguments]    ${locator}
        [Documentation]    Get all available option labels from dropdown
        Wait Until Element Is Visible    ${locator}    10s
        ${labels}=    Get List Items    ${locator}
        RETURN    ${labels}
    
    Get Page Title
        [Documentation]    Get current page title
        ${title}=    Get Title
        RETURN    ${title}
    
    Get Current URL
        [Documentation]    Get current page URL
        ${url}=    Get Location
        RETURN    ${url}
    
    Get Page Source
        [Documentation]    Get complete page source HTML
        ${source}=    Get Source
        RETURN    ${source}
    
    # Window Management Operations
    Get Current Window Position
        [Documentation]    Get current window position coordinates
        ${position}=    Get Window Position
        Log    Current window position: ${position}
        RETURN    ${position}
    
    Set Window Position
        [Arguments]    ${x}    ${y}
        [Documentation]    Set window position to specific coordinates
        Set Window Position    ${x}    ${y}
        Log    Window position set to: ${x}, ${y}
    
    Get Current Window Size
        [Documentation]    Get current window size dimensions
        ${size}=    Get Window Size
        Log    Current window size: ${size}
        RETURN    ${size}
    
    Set Window Size
        [Arguments]    ${width}    ${height}
        [Documentation]    Set window size to specific dimensions
        Set Window Size    ${width}    ${height}
        Log    Window size set to: ${width}x${height}
    
    Center Window On Screen
        [Documentation]    Center the browser window on screen
        ${screen_width}=    Execute JavaScript    return screen.width;
        ${screen_height}=    Execute JavaScript    return screen.height;
        ${window_width}=    Set Variable    1200
        ${window_height}=    Set Variable    800
        ${x}=    Evaluate    (${screen_width} - ${window_width}) // 2
        ${y}=    Evaluate    (${screen_height} - ${window_height}) // 2
        Set Window Size    ${window_width}    ${window_height}
        Set Window Position    ${x}    ${y}
    
    Minimize Browser Window
        [Documentation]    Minimize the browser window
        Execute JavaScript    window.blur();
    
    Restore Window Size
        [Arguments]    ${width}=1024    ${height}=768
        [Documentation]    Restore window to default size
        Set Window Size    ${width}    ${height}
        Maximize Browser Window
    
    # Performance and Logging Operations
    Get Browser Console Logs
        [Documentation]    Retrieve browser console logs
        ${logs}=    Get Browser Logs
        Log Many    @{logs}
        RETURN    ${logs}
    
    Log Performance Metrics
        [Documentation]    Log browser performance metrics
        ${navigation_timing}=    Execute JavaScript    return JSON.stringify(performance.getEntriesByType('navigation')[0]);
        ${paint_timing}=    Execute JavaScript    return JSON.stringify(performance.getEntriesByType('paint'));
        Log    Navigation Timing: ${navigation_timing}
        Log    Paint Timing: ${paint_timing}
    
    Measure Page Load Time
        [Documentation]    Measure and return page load time in milliseconds
        ${load_time}=    Execute JavaScript    return performance.getEntriesByType('navigation')[0].loadEventEnd - performance.getEntriesByType('navigation')[0].navigationStart;
        Log    Page load time: ${load_time} ms
        RETURN    ${load_time}
    
    Get Network Performance
        [Documentation]    Get network performance information
        ${network_info}=    Execute JavaScript    
        ...    return JSON.stringify({
        ...        connection: navigator.connection || navigator.mozConnection || navigator.webkitConnection,
        ...        onLine: navigator.onLine,
        ...        cookieEnabled: navigator.cookieEnabled
        ...    });
        Log    Network Info: ${network_info}
        RETURN    ${network_info}
    
    Set Browser Implicit Wait
        [Arguments]    ${timeout}=10s
        [Documentation]    Set implicit wait timeout for element finding
        Set Browser Implicit Wait    ${timeout}
        Log    Browser implicit wait set to: ${timeout}
    
    Log Browser Information
        [Documentation]    Log comprehensive browser information
        ${user_agent}=    Execute JavaScript    return navigator.userAgent;
        ${viewport}=    Execute JavaScript    return window.innerWidth + 'x' + window.innerHeight;
        ${screen_resolution}=    Execute JavaScript    return screen.width + 'x' + screen.height;
        ${color_depth}=    Execute JavaScript    return screen.colorDepth;
        
        Log    User Agent: ${user_agent}
        Log    Viewport Size: ${viewport}
        Log    Screen Resolution: ${screen_resolution}
        Log    Color Depth: ${color_depth}
    
    Monitor Page Resources
        [Documentation]    Monitor and log page resource loading
        ${resources}=    Execute JavaScript    
        ...    var resources = performance.getEntriesByType('resource');
        ...    var resourceInfo = resources.map(function(resource) {
        ...        return {
        ...            name: resource.name,
        ...            type: resource.initiatorType,
        ...            size: resource.transferSize,
        ...            duration: resource.duration
        ...        };
        ...    });
        ...    return JSON.stringify(resourceInfo);
        Log    Page Resources: ${resources}
        RETURN    ${resources}
    
    Clear Browser Performance Data
        [Documentation]    Clear browser performance timing data
        Execute JavaScript    performance.clearResourceTimings();
        Execute JavaScript    performance.clearMarks();
        Execute JavaScript    performance.clearMeasures();
        Log    Browser performance data cleared
    
    # Enhanced Screenshot Operations with Elements
    Compare Screenshots
        [Arguments]    ${baseline_screenshot}    ${current_screenshot}    ${threshold}=0.95
        [Documentation]    Compare two screenshots (requires additional image comparison library)
        Log    Comparing ${baseline_screenshot} with ${current_screenshot}
        # Note: This would require additional image comparison library like Pillow
        # For now, just logging the comparison request
    
    Take Screenshot On Failure
        [Documentation]    Take screenshot when test fails (for teardown use)
        ${test_name}=    Get Variable Value    ${TEST_NAME}    unknown_test
        ${timestamp}=    Get Current Date    result_format=%Y%m%d_%H%M%S
        ${filename}=    Set Variable    failure_${test_name}_${timestamp}.png
        Capture Page Screenshot    ${filename}
        Log    Failure screenshot saved: ${filename}
    
    Take Element Screenshot With Highlight
        [Arguments]    ${locator}    ${filename}=highlighted_element.png
        [Documentation]    Take screenshot of element with visual highlight
        Wait Until Element Is Visible    ${locator}    10s
        # Add visual highlight
        Execute JavaScript    arguments[0].style.border = '3px solid red';    ARGUMENTS    ${locator}
        Sleep    0.5s
        Capture Element Screenshot    ${locator}    ${filename}
        # Remove highlight
        Execute JavaScript    arguments[0].style.border = '';    ARGUMENTS    ${locator}
        Log    Highlighted element screenshot saved: ${filename}
    """
        return template
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses that the tool generates code but does not execute it, which is useful behavioral context. However, it lacks details on potential limitations (e.g., output size, error handling), authentication needs, or rate limits. For a tool with zero annotation coverage, this is a moderate gap.

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 a single, well-structured sentence that efficiently conveys the tool's purpose, scope, and output format. Every word adds value, with no redundancy or fluff. It is front-loaded with key information and appropriately concise for a zero-parameter tool.

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?

Given the tool's zero parameters, 100% schema coverage, and presence of an output schema (which handles return values), the description is reasonably complete. It explains what the tool does and the output format. However, it could improve by addressing when to use it versus siblings or noting any constraints, slightly limiting completeness.

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?

The tool has zero parameters, and the input schema has 100% description coverage (though empty). The description does not need to compensate for any parameter gaps. It appropriately focuses on the tool's function and output without unnecessary parameter details, earning a high baseline score.

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?

The description clearly states the tool's purpose: generating extended Robot Framework keywords for specific domains (screenshots, performance monitoring, window management). It specifies the output format (.robot file content as text) and clarifies it does not execute the code. However, it doesn't explicitly differentiate from sibling tools like 'create_advanced_selenium_keywords' or 'create_performance_monitoring_test', which prevents a perfect score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. With sibling tools like 'create_advanced_selenium_keywords' and 'create_performance_monitoring_test' available, there is no indication of when this tool is preferred, what prerequisites might exist, or any exclusions. This leaves the agent without context for selection.

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/sourcefuse/robotframework-mcp'

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