Automation of Login Functionality in Robot Framework

We can reduce the length of the code by creating a new resource file which includes the commonly used keywords of flight login functionalities. Let us find the unique element in the flight application page and write the test case for the same.

Open the ngendigital page and click on the Demo Application.

demo-application

You can see a login form, right-click on the email and Inspect the element

inspect-email-element

Find the XPath for the email and password.

xpath-for-email-in-flight-application

Xpath for Password

xpath-for-password-in-flight-application

We have found the unique elements for email and password, Open the Ride editor and create a new test case as Flight Application.

test-case-for-flight-application

Now, write the test case for the flight application

test-case-for-flight-alpplications

Now, select the test case and Run, once the test case starts executing, the ngendigital page will open and the email and password will be taken automatically and click on the login button and then closes the browser.

The Test Report is as shown below:

test-report-of-flight-application

The Test case is having three steps that contain the email id, password and sign in we can enhance these files by creating a new Resource file.

Let us create a new resource file as Commonlyusedkeywords

creating-resource-file-commonly-used-keywords

And, creating a new User keyword as Log in to Flight application

creating-new-user-keyword

Create new scalar variables ${username} and ${password} for commonlyusedkeywords by right-clicking on it and then open the Log in to Flight application and enter the keywords Input Text lines and then Click Element. instead of writing an actual username and password we can pass scalar variables as shown below.

writing-variables-in-user-keywords

We had created a user keyword that will be used in the flight application and hence we can use this user keyword just by importing the resource file in any of the test cases. In this way, we can reduce the length of the code. This process is known as keyword rewind functionality.

Now, add the Selenium library into the Commonlyusedkeywords, Open the commonlyusedkeywords and click on the Library under Import.

importing-selenium-library-into-resource-file

Enter the library name as SeleniumLibrary and click ok

adding-selenium-libary-to-resource-file

Now, import the Resource file into the Web Automation suite

importing-resorce-file-into-web-automation

And also, we need to import Commonlyusedkeywords resource file into the Demo project, Open the Demo project and click on the Resource below Add Import.

import-resorce-file-inti-demo-project

Once the Resource dialog box will open, click on Browser

click-on-brwoser-to-import-resource-file

Go to your robot framework project folder and then open the Demo project folder, there you will find the Commonlyusedkeywords resource file, select and then click on Open button.

select-resource-file

Once you import the resource file into the test case, the resource file will reflect inside the test suite, now open the test case and delete the input text and click element lines and insert a new keyword Log in to Flight applications.

The Enhanced functionality test case is as shown below:

functionality-enhance-test-case

Once you run the test case and you will get the same output as before.

Installation of Selenium Library

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions

Subscribe to See Videos

Subscribe to my Youtube channel for new videos : Subscribe Now