Home > Selenium > Sample script in robot framework

Sample script in robot framework

Create new file in project with .robot extension. 

Robot file contains below sections: 

  1. Setting 
  2. Variables 
  3. Keywords 
  4. Test Cases 

In setting section all imports can be defined. In variables section, Test data should be defined. In Keywords section, All operations can be defined by calling predefined keywords. In Test Cases section, All operations can be performed by calling user defined keywords.  

 

Here is the sample script to login into mercury website: 

*** Setting *** 

Library    SeleniumLibrary 

  

*** Variables *** 

${UserName}  amitb 

${Password}  amitb 

  

*** Keywords *** 

Open Mercury Tours with Chrome 

    Open Browser    http://newtours.demoaut.com/    chrome 

    Wait Until Page Contains   Registered users can sign-in 

     

Login to Mercury Tours 

    Input Text   name:userName   ${UserName} 

    Input Text   name:password   ${Password}     

    Click Element   name:login 

     

*** Test Cases *** 

TestCase1: Login Mercury Tours 

    [Documentation]  This test case is to login to mercury tour website 

    [Tags]  Smoke,Sanity 

    [Setup] 

        Open Mercury Tours with Chrome 

        Login to Mercury Tours 

    [Teardown]  

        Close Browser 

This Article is TAGGED in , , . BOOKMARK THE permalink.

Avatar photo
Amit Bharamasali
Automation Software Test Engineer. Skills: Manual Testing, Selenium, Java, Protractor, JavaScript, Katalon Studio, Groovy, Appium, Sahi, Sahi Script and UI/UX testing.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">