Saturday, November 28, 2026

get textarea or text field value in robot framework

Get Textarea Value in Robot Framework

In Robot Framework, you can get the value of a textarea using SeleniumLibrary's Get Value keyword.

get textarea or text field value in robot framework


1. Simple Example

HTML:

<textarea id="message" name="message">
Hello Robot Framework
</textarea>

Robot Framework:

*** Settings ***
Library    SeleniumLibrary

*** Test Cases ***
Get Textarea Value
    Open Browser    https://example.com    chrome

    ${textarea_value}=    Get Value    id=message

    Log To Console    ${textarea_value}

    Close Browser

Output:

Hello Robot Framework

2. Get Textarea Value Using Different Locators

${value1}=    Get Value    id=message
${value2}=    Get Value    name=message
${value3}=    Get Value    xpath=//textarea[@id='message']
${value4}=    Get Value    css=textarea#message

3. Verify Textarea Value

*** Test Cases ***
Verify Textarea Value
    ${actual_value}=    Get Value    id=message

    Should Be Equal    ${actual_value}    Hello Robot Framework
    Should Contain    ${actual_value}    Robot Framework

4. Difference Between Get Value and Get Text

Keyword Purpose
Get Value Gets the textarea's current value.
Get Text Gets the visible text content of an element.
Input Text Enters text into a textarea.
Clear Element Text Clears the textarea.

Important

For a textarea, use Get Value to retrieve the current user-entered text, including text entered dynamically after page loading.

No comments:

Post a Comment