# "DW Demo - Travel Booking (Trip.com) - Optimized", Revision 77
*** Settings ***
Documentation     A test suite with DW RF export in Gherkin style. DW Automate allows to create & maintain 1 data-driven template while generating many Robot test cases with in-line variable values. 
...								This file contains the risk-based (mixed-strength) DW suite (15 TCs) with lower priority on checkout date and rating
Library         	BuiltIn
Library				Dialogs
Library         	SeleniumLibrary

*** Variables ***
${BROWSER}           			headlesschrome
${DELAY}             			1
${START URL}         			https://www.trip.com/
${DESTINATION TXTFIELD}		//*[@id="hotels-destination"]
${CHECKIN BTN}						//*[@id="searchBoxCon"]/div/div/ul/li[2]/div/div[1]

${ROOMSPLUS BTN}					//*[@id="searchBoxCon"]/div/div/ul/li[3]/div/div[3]/div[1]/div/span[3]
${ADULTSPLUS BTN}					//*[@id="searchBoxCon"]/div/div/ul/li[3]/div/div[3]/div[2]/div/span[3]
${CHILDRENPLUS BTN}				//*[@id="searchBoxCon"]/div/div/ul/li[3]/div/div[3]/div[3]/div/span[3]
${CHILDRENNAGE DIV}				//*[@id="searchBoxCon"]/div/div/ul/li[3]/div/div[3]/div[4]/div
${CHILD1AGE DROPDOWN}			//*[@id="searchBoxCon"]/div/div/ul/li[3]/div/div[3]/div[4]/div[1]/select
${CHILD2AGE DROPDOWN}			//*[@id="searchBoxCon"]/div/div/ul/li[3]/div/div[3]/div[4]/div[2]/select
${DONE1 BTN}							//*[@id="searchBoxCon"]/div/div/ul/li[3]/div/div[3]/div[4]/span
${DONE2 BTN}							//*[@id="searchBoxCon"]/div/div/ul/li[3]/div/div[3]/div[5]/span

${WORKTRAVEL CHECKBOX}		//*[@id="searchBoxCon"]/div/div/div/div[1]/div[1]

${SEARCH BTN}		 					//*[@id="searchBoxCon"]/div/div/ul/li[5]/div


*** Test Cases ***
Valid Booking Requests_TC1_for Myrtle Beach with 1 rooms and 3 adults
    [Tags]      TAC-242 
	Given browser is opened to start page
	When user selects destination "Myrtle Beach"
	And user selects May 2023 "15" check-in date and "Jun 2023" "3" check-out date
	And user selects "1" rooms for "3" adults and "0" children
	And user "checks" work checkbox and selects "no" star rating
	Then clicking "Search" button generates results successfully

Valid Booking Requests_TC2_for Statue of Liberty with 2 rooms and 4 adults
    [Tags]      TAC-242 
	Given browser is opened to start page
	When user selects destination "Statue of Liberty"
	And user selects May 2023 "24" check-in date and "May 2023" "30" check-out date
	And user selects "2" rooms for "4" adults and "1" children
	And user "ignores" work checkbox and selects "2" star rating
	Then clicking "Search" button generates results successfully

Valid Booking Requests_TC3_for CLT with 1 rooms and 2 adults
    [Tags]      TAC-242 
	Given browser is opened to start page
	When user selects destination "CLT"
	And user selects May 2023 "31" check-in date and "Jun 2023" "12" check-out date
	And user selects "1" rooms for "2" adults and "2" children
	And user "ignores" work checkbox and selects "3" star rating
	Then clicking "Search" button generates results successfully

Valid Booking Requests_TC4_for Toronto with 3 rooms and 4 adults
    [Tags]      TAC-242 
	Given browser is opened to start page
	When user selects destination "Toronto"
	And user selects May 2023 "24" check-in date and "May 2023" "31" check-out date
	And user selects "3" rooms for "4" adults and "2" children
	And user "checks" work checkbox and selects "4" star rating
	Then clicking "Search" button generates results successfully

Valid Booking Requests_TC5_for Myrtle Beach with 1 rooms and 1 adults
    [Tags]      TAC-242 
	Given browser is opened to start page
	When user selects destination "Myrtle Beach"
	And user selects May 2023 "31" check-in date and "Jun 2023" "30" check-out date
	And user selects "1" rooms for "1" adults and "1" children
	And user "checks" work checkbox and selects "5" star rating
	Then clicking "Search" button generates results successfully

Valid Booking Requests_TC6_for Statue of Liberty with 3 rooms and 3 adults
    [Tags]      TAC-242 
	Given browser is opened to start page
	When user selects destination "Statue of Liberty"
	And user selects May 2023 "15" check-in date and "May 2023" "31" check-out date
	And user selects "3" rooms for "3" adults and "0" children
	And user "ignores" work checkbox and selects "3 or 4" star rating
	Then clicking "Search" button generates results successfully

Valid Booking Requests_TC7_for Toronto with 2 rooms and 2 adults
    [Tags]      TAC-242 
	Given browser is opened to start page
	When user selects destination "Toronto"
	And user selects May 2023 "24" check-in date and "Jun 2023" "3" check-out date
	And user selects "2" rooms for "2" adults and "0" children
	And user "checks" work checkbox and selects "5" star rating
	Then clicking "Search" button generates results successfully

Valid Booking Requests_TC8_for CLT with 1 rooms and 1 adults
    [Tags]      TAC-242 
	Given browser is opened to start page
	When user selects destination "CLT"
	And user selects May 2023 "15" check-in date and "May 2023" "31" check-out date
	And user selects "1" rooms for "1" adults and "2" children
	And user "ignores" work checkbox and selects "3 or 4" star rating
	Then clicking "Search" button generates results successfully

Valid Booking Requests_TC9_for Myrtle Beach with 2 rooms and 3 adults
    [Tags]      TAC-242 
	Given browser is opened to start page
	When user selects destination "Myrtle Beach"
	And user selects May 2023 "31" check-in date and "Jun 2023" "3" check-out date
	And user selects "2" rooms for "3" adults and "2" children
	And user "ignores" work checkbox and selects "4" star rating
	Then clicking "Search" button generates results successfully

Valid Booking Requests_TC10_for Statue of Liberty with 3 rooms and 4 adults
    [Tags]      TAC-242 
	Given browser is opened to start page
	When user selects destination "Statue of Liberty"
	And user selects May 2023 "31" check-in date and "Jun 2023" "3" check-out date
	And user selects "3" rooms for "4" adults and "0" children
	And user "checks" work checkbox and selects "5" star rating
	Then clicking "Search" button generates results successfully

Valid Booking Requests_TC11_for Toronto with 2 rooms and 2 adults
    [Tags]      TAC-242 
	Given browser is opened to start page
	When user selects destination "Toronto"
	And user selects May 2023 "15" check-in date and "May 2023" "30" check-out date
	And user selects "2" rooms for "2" adults and "1" children
	And user "ignores" work checkbox and selects "5" star rating
	Then clicking "Search" button generates results successfully

Valid Booking Requests_TC12_for Myrtle Beach with 1 rooms and 3 adults
    [Tags]      TAC-242 
	Given browser is opened to start page
	When user selects destination "Myrtle Beach"
	And user selects May 2023 "24" check-in date and "Jun 2023" "12" check-out date
	And user selects "1" rooms for "3" adults and "1" children
	And user "ignores" work checkbox and selects "no" star rating
	Then clicking "Search" button generates results successfully

Valid Booking Requests_TC13_for Toronto with 1 rooms and 1 adults
    [Tags]      TAC-242 
	Given browser is opened to start page
	When user selects destination "Toronto"
	And user selects May 2023 "24" check-in date and "May 2023" "31" check-out date
	And user selects "1" rooms for "1" adults and "0" children
	And user "ignores" work checkbox and selects "3" star rating
	Then clicking "Search" button generates results successfully

Valid Booking Requests_TC14_for CLT with 1 rooms and 4 adults
    [Tags]      TAC-242 
	Given browser is opened to start page
	When user selects destination "CLT"
	And user selects May 2023 "15" check-in date and "Jun 2023" "3" check-out date
	And user selects "1" rooms for "4" adults and "0" children
	And user "ignores" work checkbox and selects "5" star rating
	Then clicking "Search" button generates results successfully

Valid Booking Requests_TC15_for Statue of Liberty with 3 rooms and 4 adults
    [Tags]      TAC-242 
	Given browser is opened to start page
	When user selects destination "Statue of Liberty"
	And user selects May 2023 "24" check-in date and "Jun 2023" "12" check-out date
	And user selects "3" rooms for "4" adults and "1" children
	And user "checks" work checkbox and selects "2" star rating
	Then clicking "Search" button generates results successfully


*** Keywords ***
Browser is opened to start page
  Open Browser    ${START URL}    ${BROWSER}		options=add_experimental_option("excludeSwitches", ["enable-logging"])
  Set Window Size	1920	1080
  Set Selenium Speed    ${DELAY}
	Page Should Contain		Your Trip Starts Here

user selects destination "${destination}"
	Input Text		${DESTINATION TXTFIELD}		${destination}

user selects May 2023 "${checkindate}" check-in date and "${checkoutmonth}" "${checkoutdate}" check-out date
	Click Element	${CHECKIN BTN}

	Click Element	//div[@class = 'c-calendar-month__title' and text() = 'May 2023']/following-sibling::div//span[@class = 'day' and text() = '${checkindate}']
	Click Element	//div[@class = 'c-calendar-month__title' and text() = '${checkoutmonth}']/following-sibling::div//span[@class = 'day' and text() = '${checkoutdate}']

user selects "${rooms}" rooms for "${adults}" adults and "${children}" children
	Sleep 	2s
	Run Keyword If	'${rooms}' == '2'		Click Element	${ROOMSPLUS BTN}
	Run Keyword If	'${rooms}' == '3'		Double Click Element	${ROOMSPLUS BTN}

	Run Keyword If	'${adults}' == '3' and '${rooms}' in ['1','2']		Click Element	${ADULTSPLUS BTN}
	Run Keyword If	'${adults}' == '4' and '${rooms}' in ['1','2']		Double Click Element	${ADULTSPLUS BTN}
	Run Keyword If	'${adults}' == '4' and '${rooms}' == '3' 					Click Element	${ADULTSPLUS BTN}

	Run Keyword If	'${children}' == '1'	Click Element	${CHILDRENPLUS BTN}
	Run Keyword If	'${children}' == '1'	Select From List By Value	${CHILD1AGE DROPDOWN}	12

	Run Keyword If	'${children}' == '2'	Double Click Element	${CHILDRENPLUS BTN}
	Run Keyword If	'${children}' == '2'	Select From List By Value	${CHILD1AGE DROPDOWN}	<1
	Run Keyword If	'${children}' == '2'	Select From List By Value	${CHILD2AGE DROPDOWN}	17

	Run Keyword If	'${children}' == '0'	Click Element	${DONE1 BTN}
	Run Keyword If	'${children}' != '0'	Click Element	${DONE2 BTN}

user "${workcheckbox}" work checkbox and selects "${rating}" star rating
	Run Keyword If	'${workcheckbox}' == 'checks'						Click Element	${WORKTRAVEL CHECKBOX}
	Run Keyword If	'${rating}' in ['2', '3', '4', '5']			Click Element	//*[@id="searchBoxCon"]/div/div/div/div[2]/span[${rating}]
	Run Keyword If	'${rating}' == '3 or 4'									Click Element	//*[@id="searchBoxCon"]/div/div/div/div[2]/span[3]
	Run Keyword If	'${rating}' == '3 or 4'									Click Element	//*[@id="searchBoxCon"]/div/div/div/div[2]/span[4]

clicking "Search" button generates results successfully
	Click Element			${SEARCH BTN}
	Page Should Contain		properties found
	Close Browser