Your ultimate guide

Handling Text Box Using Robot Framework



Input Text: This keyword is used to give text into the text field identified by the locator.
    Syntax: Input Text    locator    text

Clear Element Text: This keyword is used to Clear the value of the text-input element identified by the locator.
    Syntax: Clear Element Text    locator

Click Button: This keyword is used to Click the button identified by the locator.
    Syntax: Click Button    locator
Note: By default, buttons are searched using id, name and value.



Example Test Case:
  1. Open Browser Navigate to Demo Form URL: https://testingcolleges.blogspot.com/2023/08/demo-form.html
  2. Enter First Name as "Testing" and Last Name as "Colleges".
  3. Give the email ID: "123@gmail.com"
  4. Then Remove the above email ID and Add a new id: abc@gmail.com.
  5. Click on Submit button.
  6. Close the Browser.

Program:
  1. *** Settings ***
  2. Library    SeleniumLibrary
  3. *** Variables ***
  4. ${url}      https://testingcolleges.blogspot.com/2023/08/demo-form.html
  5. ${firstName}    Testing
  6. ${lastName}     Colleges
  7. ${email}    123@gmail.com
  8. ${email2}   abc@gmail.com
  9. *** Test Cases ***
  10. TextBox
  11.     Open Browser    ${url}  Chrome
  12.     Input Text    id:fname  ${firstName}
  13.     Input Text    id:lname  ${lastName}
  14.     Input Text    id:mail   ${email}
  15.     Sleep    2
  16.     Clear Element Text    id:mail
  17.     Input Text    id:mail   ${email2}
  18.     Click Button    Submit
  19.     Sleep    2
  20.     Close Browser
Output:


No comments:

Post a Comment