From 8b01b6c7a158ca7973a0393ee8344ee151a82de9 Mon Sep 17 00:00:00 2001 From: BalamiRR Date: Wed, 19 Feb 2025 16:31:35 +0100 Subject: [PATCH] DONE: Scenario: Adding a child and selecting a random child age --- .../flights_hotels.feature.robot | 7 ++++-- .../frontend/flights_hotels.steps.robot | 24 ++++++++++++++----- step-definition/frontend/webelements.py | 2 +- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/features-frontend/flights_hotels.feature.robot b/features-frontend/flights_hotels.feature.robot index a8f86a9..7905442 100644 --- a/features-frontend/flights_hotels.feature.robot +++ b/features-frontend/flights_hotels.feature.robot @@ -1,5 +1,6 @@ *** Settings *** Resource ../step-definition/frontend/flights_hotels.steps.robot +Resource ../step-definition/frontend/stays.steps.robot Force Tags UC-FLIGHTS-HOTELS Suite Setup Open BookingApp Test Teardown Run Keyword If Test Failed Capture Page Screenshot @@ -43,8 +44,8 @@ Scenario: Assign a new destination to a destination field ... Select a destination randomly from the item proposed in the list ... Ensure that the new destination is assigned to the destination field [Tags] Medium - Given I select a random destination from the list - Then The destination will be assigned to the destination field + Given I select a random destination for hotels and flights from the list + Then I will see that destination will be assigned to the destination field Scenario: Clear button for departure and destination [Documentation] @@ -81,6 +82,8 @@ Scenario: Adding a child and selecting a random child age [Tags] Low Given I click on the "Add a child" option Then I will see the list of ages til 12 years + When I select a random age for the child from the list + Then I will see the newly added child's age displayed Scenario: Adding a new room [Documentation] This scenario verifies that a new room can be added successfully and appears next to the first room. diff --git a/step-definition/frontend/flights_hotels.steps.robot b/step-definition/frontend/flights_hotels.steps.robot index a80f0c8..3688a74 100644 --- a/step-definition/frontend/flights_hotels.steps.robot +++ b/step-definition/frontend/flights_hotels.steps.robot @@ -75,7 +75,7 @@ I see related cities or airports for destination ${lenght_destination}= Get Length ${destination_items} RETURN ${destination_items} ${lenght_destination} -I select a random destination from the list + I select a random destination for hotels and flights from the list ${destination_items} ${destination_count} I see related cities or airports for destination ${random_index} Evaluate random.randint(0, ${destination_count}-1) ${selected_destination} Get Text ${destination_items}[${random_index}] @@ -84,7 +84,7 @@ I select a random destination from the list Set Global Variable ${selected_destination} [Return] ${selected_destination} -The destination will be assigned to the destination field +I will see that destination will be assigned to the destination field ${destination_assigned} Get Value ${ASSIGNED_DESTINATION} Should Start With ${selected_destination} ${destination_assigned} @@ -151,13 +151,25 @@ I will see the any class option is selected as default I click on the "Add a child" option Click Element ${ADD_CHILD_BTN} -I will see the ages til 12 years +I will see the list of ages til 12 years Wait Until Element Is Visible ${AGE_LIST} ${age_items} Get WebElements ${AGE_LIST} - ${l}= Get Length ${age_items} + ${length_of_ages}= Get Length ${age_items} Set Global Variable @{age_items} - Set Global Variable ${l} - RETURN ${age_items} ${l} + Set Global Variable ${length_of_ages} + RETURN ${age_items} ${length_of_ages} + +I select a random age for the child from the list + ${age_items} ${age_numbers} I will see the list of ages til 12 years + ${random_age} Evaluate random.randint(0,${age_numbers}-1) + ${selected_age} Get Text ${age_items}[${random_age}] + Click Element ${age_items}[${random_age}] + Sleep 1s + Set Global Variable ${selected_age} + [Return] ${selected_age} + +I will see the newly added child's age displayed + Log message I click on the "Add a Room" button Log message diff --git a/step-definition/frontend/webelements.py b/step-definition/frontend/webelements.py index 5d8e19d..dbded15 100644 --- a/step-definition/frontend/webelements.py +++ b/step-definition/frontend/webelements.py @@ -47,7 +47,7 @@ FLIGHT_HOTEL_ACCEPT_COOKIES="css=button.iubenda-cs-accept-btn" ASSIGNED_DEPARTURE="(//div[@class='d-28ke2m ed5mks93'])[1]/input" DESTINATION_FLIGHT_HOTEL_FIELD="//input[@placeholder='Where do you want to go?']" -LIST_OF_DESTINATION="//ul[@id=':R3a6j6lalqmt2mmH2:']/li/ul/li" +LIST_OF_DESTINATION="//ul[@class='d-1ip0gkj']/li/ul/li" ASSIGNED_DESTINATION="(//div[@class='d-28ke2m ed5mks93'])[2]/input" CLEAR_DEPARTURE_DESTINATION="(//button[@class='d-l65ey4 ed5mks91'])[1]" SWITCH_BUTTON="css=.ButtonFlip-module__flipIcon___2sPKY > svg"