Thursday, 23 March 2023

selenium robot

 1. sections

  • lines starting with *** denote sections
  • they have a special meaning and serve as a way to organise the file
*** Settings ***
*** Variables ***
*** Test Cases ***
*** Keywords *** 

2. pre-defined keyword
  • selenium2Library comes with many predefined keywords like “Open Browser”

3. sample .robot file

*** Settings ***
Library           SeleniumLibrary

*** Variables ***
${URL}            https://the-internet.herokuapp.com/login
${BROWSER}        chrome

*** Test Cases ***
Login Test
    Open Browser To Login Page
    Input Credentials
    Verify Successful Login
    [Teardown]    Close Browser

*** Keywords ***
Open Browser To Login Page
    Open Browser    ${URL}    ${BROWSER}

Input Credentials
    Input Text    id=username    tomsmith
    Input Text    id=password    SuperSecretPassword!
    Click Button    css=button[type="submit"]

Verify Successful Login
    Wait Until Page Contains    Welcome to the Secure Area
    Location Should Be    https://the-internet.herokuapp.com/secure


reference

No comments:

Post a Comment