Automation of Login Functionality

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 and write the test case for the same.

Open the ngendigital page and click on the Demo Application. You can see a login form, right-click on it and inspect the 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 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 use keyword as Login to Flight application

creating-new-user-keyword

Create new scalar variables for commonlyusedkeywords by right-clicking on it and then open the test case and copy the input text lines and the Click element.

copying-the-input-text

Now, paste it into the user keyword, 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, right-click on the commonlyusedkeywords and click on the library under import and enter the library name as SeleniumLibrary.

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 this resource file into the demo project

importing-commonly-used-keywords

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 Login to flight application.

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.



K

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions