Manage Booking in Robot Framework

As soon as you log in to the flight application, you can see a four tab containing Search Flights, Manage Booking, Check-in, and Logout options. In this article, we are going to discuss the features which are present in the Manage Booking.

As it contains flight booking options such as From and To, Start date and End date, and Round trip options. We can also select the class to book our Tickets, Which tells about different types of classes such as Economy, Business and First class.

Manage Booking also contains an option to book an only Flight or Flight + Hotel. The Manage Booking page looks as below

book-flight-page

Now, let us discuss different types of test scenarios under Manage Booking

Database Library in Robot Framework

First Test Case in Robot Framework

Test Scenario Testcase Name Test Steps Description Expected Result
Static Validation TC01_Book a Flight-Round trip between To and From Destinations_verify "From"cities Step1 Open Browser and Enter URL <www.ngendigital.com/demo-application> Flight Application Login page will be displayed.
Step2 Enter username-support@ngendigital.com and password-abc123 and click on Sign in Flight Application Login page will be displayed. Verify the page contains the title-Book your flight, and a tab displaying four links-Search Flight, Manage Booking, Check-in, and Logout
Step3 Click on the link Manage Booking Manage Booking page is displayed it contains From and To destinations, start and Return dates, drop to select class, Checkbox for the round trip, and radio button for Flight and Flight+Hotel
Step4 Click on From City Validate the List contains Toronto, Chicago, New York, London
Step5 Click on Logout User is logout verify login page is displayed.
Step6 Close Browser Browser is Closed

Open the ngendigital/demo-application page and enter the valid username and password and then click on the Sign-In button. Right-click on the Sign-in and inspect the element and then write the Xpath for the same.

writing-xpath-for-signin-button

Save this Xpath in Notepad and Sign in to the flight application page and inspect every element present on this page and write the Xpath for those elements and then make a list of all the Xpath.

Sign in: //div[contains(text(),'Sign In')]

FromCity://select[@id='FromCity']

ToCity://select[@id='ToCity']

Start Date://input[@id='goDate']

Return://input[@id='returnDate']

Class://select[@id='Class']

Round Trip(Checkbox button)://input[@name='roundtrip']

Flight(Radio button)://input[@value='flight']

Flight+Hotel: //input[@value='flighthotel']

Now, go back to ride editor and create a new test suite Flight Application-Manage Booking and import selenium library, Excel Library and commonkeywords resource file and create a new test case as TC01_Book a Flight-Round trip between To and From Destinations_verify "From"cities

Since we are going to deal with two iframes and hence pass an argument ${text1} in the change to iframe keyword as below.

passing-an-argumnet-to-the-chnage-iframe-keyword

So, you need to enter the variable whenever you are using the change to the iframe keyword in any test cases. And start writing the test case. Create new user keyword in the commonkeywords as validationonmanagebooking

The Validationonmanagebooking keyword is:

validation-on-manage-booking

Create another one new user keyword called validatefromcity and create a new list variable @{cities} and a scalar variable ${Response} which should contain four values Toronto, Chicago, New York, and London.

creating-new-keyword-response

And the Validatefromcity look as below:

validate-from-city

And create another user keyword as Logout which contains Click Element and Element Text Should Be keywords

logout-keyword

Now go back to test case, and the complete test case looks like as shown below

tc01-book-flight-round-trip

Select the test case and run, once the test case starts executing, it will navigate to the flight application page and login with the username and password and then click on the Manage booking nad verify all the options which are present in the manage booking and then logout from the website.

Automation of Desktop Application Using Robot Framework

Second Test Case in Robot Framework

The Second tets case similar to the first one but, here we need to verify ToCity instead of FromCity

Test Scenario Testcase Name Test Steps Description Expected Result
Static validation and TC02_Book a Flight-Round trip between To and From Destinations_verify "To" cities Step1 Open the browser and enter URL <www.ngendigital.com/demoapplication> Flight application login page will be displayed
Step2 Enter username-support@ngendigital.com and password abc123, Click on Sign in Flight Application Login page will be displayed. Verify the page contains the title-Book your flight, and a tab displaying four links-Search Flight, Manage Booking, Check-in, and Logout
Step3 Click on the link Manage Booking

Manage Booking tab is displayed, it contains from and to destinations, starts and return dates, Dropdown to select class, checkbox and Radio button for Flight and Flight+Hotel

Step4 Click on To City Validate the list contains Paris, Tokyo, Mumbai, and Atlanta
Step5 Click on Logout User is logged out verify login page is displayed
Step6 Close Browser Browser is closed

Go back to the ride editor and create a new test case as TC02_Book a Flight-Round trip between To and From Destinations_verify "To" cities and until validationonmanagebooking, you can copy from TC01_Book a Flight-Round trip between To and From Destinations_verify "From"cities.

Create a new user keyword ValidateToCity and create another scalar variable called ${Response2} and pass the values as below.

creating-new-scalar-var-response2

Now enter this keyword in the test case TC02_Book a Flight-Round trip between To and From Destinations_verify "To" cities and select the tets case and RunOnce you run the test case, it will navigate to the ngendigital/demo-application page and open the manage booking tab and then verifies the option To City.

tc02-To-city-test-case-robot-framework

GitHub with Robot Framework Flight Application

Third Test Case in Robot Framework

In this test case, we are going to discuss another scenario from Manage Booking

Test Scenario Testcase Name Test Steps Description Expected Result
Static Validation TC03_Book a Flight-Round trip between To and From Destinations_verify "Class." Step1 Open the browser and enter URL <www.ngendigital.com/demo-application> Flight application login page will be displayed
Step2 Enter username-support@ngendigital.com and password abc123, Click on Sign in Flight Application Login page will be displayed. Verify the page contains the title-Book your flight, and a tab displaying four links-Search Flight, Manage Booking, Check-in, and Logout
Step3 Click on the link Manage Booking Manage Booking tab is displayed, it contains from and to destinations, starts and return dates, Dropdown to select class, checkbox and Radio button for Flight and Flight+Hotel
Step4 Click on From Class Validate the list contains Economy, Business and First class
Step5 Click on Logout User is logged out verify login page is displayed
Step6 Close Browser Browser is closed

Now, go back to the ride editor and create a new test case as TC03_Book a Flight-Round trip between To and From Destinations_verify "Class". And create a new user keyword called validateclass and open the tets case and copy and paste steps from loginandnavigatetourl till validationonmangebooking in the third test case.

And create one scalar variable called verifyclass with the values as shown below

verify-class-scalar-variable

The Validateclass is:

validate-class-keyword

And the TC03_Book a Flight-Round trip between To and From Destinations_verify "Class" test case is:

testcase-03-verify-class

Select the test case and run, once it starts executing, it will navigate to the ngendigital/demo-application page and opens the manage booking and then verifies the class elements.

Working with Robot Framework Jenkins

Fourth Test Case in Robot Framework

Test Scenario Testcase Name Test Steps Description Expected Result
Static validation TC04_Book a Flight-Verify Radio Button should not be select by default Step1 Open the browser and enter URL <www.ngendigital.com/demo-application> Flight application login page will be displayed
Step2 Enter username-support@ngendigital.com and password abc123, Click on Sign in Flight Application Login page will be displayed. Verify the page contains the title-Book your flight, and a tab displaying four links-Search Flight, Manage Booking, Check-in, and Logout
Step3 Click on the link Manage Booking Manage Booking tab is displayed, it contains from and to destinations, starts and return dates, Dropdown to select class, checkbox and Radio button for Flight and Flight+Hotel
Step4 verify that radio button both flight and flight
+hotel is not selected by default
Both radio buttons are not selected by default
Step5 Click on Hotel The hotel radio button is selected
Step6 verify that hotel+flight is not selected Hotel+Flight is not selected
Step7 Click on Log out User is logged out verify login page is displayed

In this test case,

  • We have to verify that when we click on the radio button, both flight and flight+hotel applications are selected by default.
  • The next one is when we click on the Hotel, we have to verify that the Flight+Hotel is not selected.

Go back to the ride editor and create a new test case by the name TC04_Book a Flight-Verify Radio Button should not be select by default.

The Steps from Loginandnavigatetourl till validationonmanagebooking is same as the third test case, and hence you can copy and paste into the TC04_Book a Flight-Verify Radio Button should not be select by default the test case, create a new commonkeyword called Radiobutton Validation

radio-button-validation-keyword

The keyword in the above image Radio Button Should Not Be Selected requires the parameter group name, if you navigate to the URL and inspect the Radio Button element, you can see that the element has the group name as flight so that you can mention that group name in the keyword as above.

And the next keyword Select Radio Button Requires the parameter as the group name and value, so the Radio Button contains Flight as both group name and the value. And the next keyword is a negative keyword; we are making an error to occur to pass the test case.

grouop-name-as-an-argument

Now, goto fourth test case and include the new keyword Radiobutton validation and save then run the same.

The test case is as shown:

test-case-verify-radio-button

Now, select the test case and run. Once the test case starts executing, it will navigate to the URL, and it verifies the radio button, and when we select the Flight option, it verifies that the Flight+Hotel has not selected. The Robot Framework will be logged out from the Demo-application page and verifies the login page.

Web Elements of Robot Framework

Fifth Test Case in Robot Framework

In this test case, we are going to discuss the positive test cases

Test Scenario Testcase Name Test Steps Description Expected Result
Positive Test Cases TC05_Book a flight-One way trip between To and From Destinations_FromToronto to Paris_Economy Step1 Open the browser and enter URL <www.ngendigital.com/demo-application> Flight application login page will be displayed
Step2 Enter username-support@ngendigital.com and password abc123, Click on Sign in Flight Application Login page will be displayed. Verify the page contains the title-Book your flight, and a tab displaying four links-Search Flight, Manage Booking, Check-in, and Logout
Step3 Click on the link Manage Booking Manage Booking tab is displayed, it contains from and to destinations, starts and return dates, Dropdown to select class, checkbox and Radio button for Flight and Flight+Hotel
Step4 Choose From-Toronto, To-Paris, Start date-2019/06/21, Return date-2019-06-28. Choose the class Economy. Check Round Trip and Choose Flight+Hotel radio Button. Click on Get Fare. A Table displaying the fares for the confirmation of the following start and return dates. Start dates-19-jun,20-jun,21-jun,22-jun,23-jun and return dates-26-jun,27-jun,28-jun,29-jun,30-jun
Step5 Click on confirm Booking The Flight will be booked displaying the message Success! Your flight is booked.
Step6 Click on Logout User is logged out, verify login page is displayed

Navigate to the URL ngendigital/demo-application and select the Manage booking and then set the From and To places and set the start and return dates as shown below:

booking-flight-manage-booking

inspecting-1955-amount-robot-framework

The message will be displayed as shown below.

success-your-flight-is-booked

Except Get Fare we have Xpath for all the elements which are present in the Manage booking page, so let us find out the Xpath for Get Fare.

xpath-for-get-fare

Now, click on the Get Fare and select fare as 1955, Inspect the amount 1955 and write the Xpath for the same

xpath-for-1955

Finding the Xpath for Confirm Booking, right-click on the Confirm Booking and inspect the element and then write the Xpath for the same

inspect-confirm-booking-tab

xpath-for-confirm-booking

The next step is to find the Xpath for Success!! your flight is booked, so we did not get the Xpath for this. Let us go back to the ride editor and create a new test case by the name TC05_Book a flight-One way trip between To and From Destinations_FromToronto to Paris_Economy. Create a new commonkeyword as Book fisrtfare flight And import the Date and Time library into the commonkeywords. And create two new scalar variables as shown below

scalar-variable-date1

scalar-variable-date2

Go back tobook firstfare flight and continue adding a script data

book-first-fare-flight

The complete data of Book firstfare flight is as follow:

Set Selenium Speed 0.5
List Selection Should Be
xpath://select[@id='FromCity']
Toronto
List Selection Should Be xpath://select[@id='ToCity'] Paris
Input Text xpath://select[@id='goDate] ${date1}
Input Text xpath://select[@id='returnDate] ${date2}
Wait Until Keyword Succeeds 2 1 Select From List By Index xpath://select[@id='Class']
Select Radio Button flight flight
Click Button xpath://button[contains(text(),'Get Fare')]
Click Element xpath://div[@id='FareFirst']//tbody/tr[4]/td[4]
Click Button xpath://div[@id='FareFirst']//button[@id='confirm']
Page Should Contain SUCCESS !! Your flight is booked

Go back to the test case and enter the new keyword into it and run the test case.

tc05-verify-to-and-from-destinations

Once the test case starts executing, it opens the browser and navigates to the URL and click on the manage booking and then it will set the start and the return dates and then select the class Economy. Check Round Trip and Choose Flight+Hotel, click on get fare and selects the fare then confirm the booking. Logged out from the demo-application and then verifies the login page.

We are going to select the Different From and To places for the same test case as shown below

different-destinations

Now go back to the ride editor and create a new test case TC06_NewYork to Mumbai and create a new commonkeywords as Book economy

book-economy

The complete data for the Book Economy is:

Set Selenium Speed 0.5
List Selection Should Be xpath://select[@id='FromCity'] 1
List Selection Should Be xpath://select[@id='ToCity'] 2
Input Text xpath://select[@id='goDate] ${date1}
Input Text xpath://select[@id='returnDate] ${date2}
Wait Until Keyword Succeeds 2 1 Select From List By Index xpath://select[@id='Class'] 0
Select Radio Button flight flight
Click Element xpath://div[@id='FareFirst']//tbody/tr[4]/td[4]
Click Button xpath://div[@id='FareFirst']//button[@id='confirm']
Page Should Contain SUCCESS !! Your flight is booked

And the test case is

test-cse-tc06-newyork-to-mumbai

Now, select the test case and run, once the test case starts executing, it will navigate to the URL and verifies the elements, from and to cities, and then verifies the economy class.

User-Defined Keywords Using Python in Robot Framework

Sixth Test Case in Robot Framework

In this test case, we are going to discuss the negative part of the test case. When you click on the Get Fare button without selecting Flight or Flight+Hotel, you will get a message as Please choose one of Flight or Flight + Hotel!

please-choose-one-of-flight-flighthotel

Go back to the ride editor and create a new test case as TC07_Select either Flight/Hotel

tc07-select-either-flight-hotel

Now, select the test case and run. Once the test case starts executing, it verifies that if the user does not select any options either Flight or Flight+Hotel, then displays the message as Please Choose one of Flight or Flight+Hotel!

Excel Library in Robot Framework

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions

Subscribe to See Videos

Subscribe to my Youtube channel for new videos : Subscribe Now