def check_availability(reservation_date,reservation_time,party_size,restaurant_name):
    try:
        #Convert User Defined Values to System Usable Values
        reservation_day=reservation_date.split('/')[0]
        reservation_month =reservation_date.split('/')[1]
        reservation_month=int(reservation_month)-1
        reservation_year =reservation_date.split('/')[2]
        reservation_time_int=int(reservation_time)
        start_time_hr= reservation_time[:2]
        if reservation_time_int>1159:
            if start_time_hr!="12":
                start_time_hr=int(start_time_hr)-12
            start_time_option = str(start_time_hr)+":"+reservation_time[2:4]+" pm"
        else:
            start_time_option = str(start_time_hr)+":"+reservation_time[2:4]+" am"
             
        #Booking Parameters
        chope_url ='https://www.chope.co/singapore-restaurants/category/restaurant/'
        t.init()
        t.url(chope_url) 
        t.wait(10)
        #Date Field
        t.click(f"(//span[contains(@class,'input-group-addon icon-calendar')])[1]")
        t.wait(7)
        boolean_flag=1
        while boolean_flag:
            if t.present(f"//td[@data-handler='selectDay'and @data-year='{reservation_year}' and @data-month='{reservation_month}']/a[text()='{reservation_day}']"):
                t.click(f"//td[@data-handler='selectDay'and @data-year='{reservation_year}' and @data-month='{reservation_month}']/a[text()='{reservation_day}']")
                boolean_flag=0
            else:
                t.click('//a[@title="Next"]')
        t.click(f"//td[@data-handler='selectDay'and @data-month='{reservation_month}']/a[text()='{reservation_day}']")
        #Time Field
        t.select(f"//select[contains(@id,'time-field')]",start_time_option)
        #Number of Diners Field
        t.click(f"(//span[contains(@class,'input-group-addon icon-person')])[1]")
        t.select(f"//select[contains(@id,'adults')]",party_size)
        #Restaurant Field
        t.type(f"//select[contains(@id,'sb-sel-restaurant')]",restaurant_name)
        t.click('//button[@id="btn-search"]')
        t.wait(5)
        if t.present(f"//div[@class='alert alert-danger']"):
            print('Not Available')
            return 0
        else:
            print ('Available')
            return 1
    except:
        print('Error')
        return 'Reservation Unsuccessful. Unforunately, the restaurant was not able to accomodate your reservation.'
Beispiel #2
0
 def search_keyword(self, keyword):
     clear_button = '//button[@aria-label="Exit Search"]'
     search_button = '//button[@aria-label="Search"]'
     if t.present(clear_button):
         click(clear_button)
         type_into('//input[contains(@aria-label, "Search")]', keyword)
         click(search_button)
def wait_for_pageload(selector):
    wait_status = 0
    for loop_wait in range(1, 20):
        print(f"{loop_wait}. waiting for page to appear. wait for 1s...")
        if t.present(selector):
            wait_status = 1
            break
        else:
            t.wait(1)
    print("bp801.2 wait_status = {}".format(wait_status))
def wait_for_mainpageload(selector):
    wait_status = 0
    result = 1
    for loop_wait in range(1, 15):
        print(f"{loop_wait}. waiting for page to appear. wait for 1s...")
        if t.present(selector):
            wait_status = 1
            break
        else:
            t.wait(1)
            if loop_wait == 14:
                result = 0
    return result

    print("bp801.2 wait_status = {}".format(wait_status))
def read_if_present(selector):
    str = ""
    if t.present(selector):
        str = t.read(selector)
    return str
Beispiel #6
0
def wait_element(xpath, timeout=7):
    for i in range(timeout):
        if t.present(xpath):
            return True
        t.wait(1)
    return False
Beispiel #7
0
def getExpFlightPrice(airline, dep_ref, dur_ref):
    print(airline)
    print(dep_ref)
    print(dur_ref)
    util.wait_for_pageload('//input[@classes="filter-checkbox"]')

    t.wait(3)
    t.click(f'//a[@data-content-id="airlineToggleContainer"]')

    for i in range(len(dep_ref)):
        if i == 0:
            if t.present(f'//input[@id="airlineRowContainer_{airline[i]}"]'):
                t.wait(3)
                t.click(f'//input[@id="airlineRowContainer_{airline[i]}"]')
            else:
                print('Not match')
                return 0, ''

        elif airline[i] != airline[i-1]:
            if t.present(f'//input[@id="airlineRowContainer_{airline[i]}"]'):
                t.wait(1)
                t.click(f'//input[@id="airlineRowContainer_{airline[i]}"]')
            else:
                print('Not match')
                return 0, ''

        if dep_ref[i][0] == '0':
            dep_ref[i] = dep_ref[i][1:]

        if dur_ref[i][-1:] == 'h':
            dur_ref[i] = dur_ref[i] + ' 0m'
        else:
            dur_ref[i] = dur_ref[i] + 'm'


    print(airline)
    print(dep_ref)
    print(dur_ref)

    util.wait_for_pageload('//button[@data-test-id="select-button"]')
    t.wait(5)
    for i in range(t.count(f'//ul[@id="flightModuleList"]//li')):
        i = i + 1
        print(i)
        dep = t.read(f'(//span[@class="medium-bold"]//span[@data-test-id="departure-time"])[{i}]')
        if len(dur_ref) == 1:
            if dep == dep_ref[0]:
                print('dep OK')
                dur = t.read(f'(//span[@data-test-id="duration"])[{i}]')
                t.click(f'(//button[@data-test-id="select-button"])[{i}]')
                t.wait(5)
                if t.present('//a[@id="forcedChoiceNoThanks"]'):
                    t.click(f'//a[@id="forcedChoiceNoThanks"]')
                t.wait(5)
                for x in range(5):
                    print(x)
                    if t.popup('Flight-Information?'):
                        break
                    else:
                        t.wait(5)
                price = t.read(f'(//span[@class="packagePriceTotal"])[2]')
                price = float(price.replace(',', '').replace('SG', '').replace('$', '').replace(' ', ''))
                print(price)
                url = t.url()
                return price, url
            else:
                return 0, ''

        elif len(dur_ref) == 2:
            print('trip', len(dur_ref))
            if dep == dep_ref[0]:
                print('dep OK')
                dur = t.read(f'(//span[@data-test-id="duration"])[{i}]')

                t.click(f'(//button[@data-test-id="select-button"])[{i}]')
                t.wait(5)

                util.wait_for_pageload('//button[@data-test-id="select-button"]')
                t.click(f'//input[@id="airlineRowContainer_{airline[1]}"]')
                t.wait(2)
                for j in range(t.count(f'//ul[@id="flightModuleList"]//li')):
                    j = j + 1
                    print(j)
                    dep = t.read(f'(//span[@data-test-id="departure-time"])[{j}+1]')
                    if dep == dep_ref[1]:
                        print('return dep ok')
                        dur = t.read(f'(//span[@data-test-id="duration"])[{j}+1]')

                        if dur == dur_ref[1]:
                            t.click(f'(//button[@data-test-id="select-button"])[{j}]')
                            t.wait(5)
                            if t.present('//a[@id="forcedChoiceNoThanks"]'):
                                t.click(f'//a[@id="forcedChoiceNoThanks"]')
                            t.wait(5)
                            for x in range(5):
                                print(x)
                                if t.popup('Flight-Information?'):
                                    break
                                else:
                                    t.wait(5)
                            util.wait_for_pageload('//h1[@class="section-header-main"]')
                            price = t.read(f'(//span[@class="packagePriceTotal"])[2]')
                            price = float(price.replace(',', '').replace('SG', '').replace('$', '').replace(' ', ''))
                            print(price)
                            url = t.url()
                            print(url)
                            return price, url
            else:
                return 0, ''

        elif len(dur_ref) >= 3:
            dep_lst = []
            dur_lst = []
            print('multi-trip ', len(dur_ref))
            for k in range(len(dur_ref)):
                dep_lst.append(t.read(f'(//span[@data-test-id="departure-time"])[{3*i+k+1}]'))
                dur_lst.append(t.read(f'(//span[@data-test-id="duration"])[{3*i+k+1}]'))
            print(dep_lst)
            print(dep_ref)
            if dep_lst == dep_ref:
                print(dur_lst)
                print(dur_ref)
                if dur_lst == dur_ref:
                    t.click(f'(//button[@data-test-id="select-button"])[{j}]')
                    t.wait(5)
                    if t.present('//a[@id="forcedChoiceNoThanks"]'):
                        t.click(f'//a[@id="forcedChoiceNoThanks"]')
                    t.wait(5)
                    for x in range(5):
                        print(x)
                        if t.popup('Flight-Information?'):
                            break
                        else:
                            t.wait(5)
                    price = t.read(f'(//span[@class="packagePriceTotal"])[2]')
                    price = float(price.replace(',', '').replace('SG', '').replace('$', '').replace(' ', ''))
                    print(price)
                    url = t.url()
                    print(url)
                    return price, url
            else:
                return 0, ''
Beispiel #8
0
def getFlightInfo(date, ind):
    t.wait(2)
    util.wait_for_pageload('//div[@class="ResultsSummary_summaryContainer__3_ZX_"]//span[@class="BpkText_bpk-text__2NHsO BpkText_bpk-text--sm__345aT SummaryInfo_itineraryCountContainer__30Hjd"]')

    price_lst = []
    href_lst = []
    deal_lst = []
    type = len(date)
    time_lst = []
    code_lst = []
    details_lst = []


    dur_ref = []

    for n in range(2):
        leg_lst = []
        bound_lst = []
        time_dep_lst = []
        time_arr_lst = []
        time_arr_day_lst = []
        airline_lst = []
        dur_lst = []
        transfer_lst = []
        transfer_plc_lst = []
        index_lst = []


        if t.present('//span[@class="BpkBadge_bpk-badge__2mEjm "]'):
            k = n + 1
        else:
            k = n

        ### href and price check
        href = t.read(f'(//a[@class="FlightsTicket_link__kl4DL"])[{n + 1}]//@href')
        if t.present('//span[@class="BpkText_bpk-text__2NHsO BpkText_bpk-text--sm__345aT Price_totalPrice__24xz2"]'):
            price = t.read(f'(//div[@class="BpkTicket_bpk-ticket__Brlno BpkTicket_bpk-ticket--with-notches__2i2HX"])[{k+1}]//div//div[@class="TicketStub_horizontalStubContainer__2aEis"]//div//span[@class="BpkText_bpk-text__2NHsO BpkText_bpk-text--sm__345aT Price_totalPrice__24xz2"]')
            price_lst.append(float(price.replace(',', '').replace(' total', '').replace('$', '')))
            print(price_lst)
        else:
            price = t.read(f'(//div[@class="BpkTicket_bpk-ticket__Brlno BpkTicket_bpk-ticket--with-notches__2i2HX"])[{k+1}]//div//div[@class="TicketStub_horizontalStubContainer__2aEis"]//div//div//span')
            price_lst.append(float(price.replace(',', '').replace('$', '')))
            print(price_lst)
        ind = ind + 1
        print(ind)

        for i in range(type):
            leg = i+1
            print(leg)

            code = t.read(
                f'(//div[@class="BpkTicket_bpk-ticket__Brlno BpkTicket_bpk-ticket--with-notches__2i2HX"])[{k+1}]//div//div//div//div[@class="LegDetails_container__11hQT TicketBody_leg__1_ia3"][{i+1}]//div//div//div//img[@class="BpkImage_bpk-image__img__3HwXN"]/@src')
            airline = t.read(f'(//div[@class="BpkTicket_bpk-ticket__Brlno BpkTicket_bpk-ticket--with-notches__2i2HX"])[{k+1}]//div//div//div//div[@class="LegDetails_container__11hQT TicketBody_leg__1_ia3"][{i+1}]//div//div//div//img[@class="BpkImage_bpk-image__img__3HwXN"]/@alt')

            print(airline)
            code_lst.append(code[43:45])
            print(code_lst)
            time_dep = t.read(f'(//div[@class="BpkTicket_bpk-ticket__Brlno BpkTicket_bpk-ticket--with-notches__2i2HX"])[{k+1}]//div//div//div//div[@class="LegDetails_container__11hQT TicketBody_leg__1_ia3"][{i+1}]//div//div[@class="LegInfo_routePartialDepart__37kr9"]//span//div//span')
            time_arr = t.read(f'(//div[@class="BpkTicket_bpk-ticket__Brlno BpkTicket_bpk-ticket--with-notches__2i2HX"])[{k+1}]//div//div//div//div[@class="LegDetails_container__11hQT TicketBody_leg__1_ia3"][{i+1}]//div//div[@class="LegInfo_routePartialArrive__ZsZxc"]//span//div//span[@class="BpkText_bpk-text__2NHsO BpkText_bpk-text--lg__3vAKN"]')
            dur = t.read(f'(//div[@class="BpkTicket_bpk-ticket__Brlno BpkTicket_bpk-ticket--with-notches__2i2HX"])[{k+1}]//div//div//div//div[@class="LegDetails_container__11hQT TicketBody_leg__1_ia3"][{i+1}]//div//div[@class="LegInfo_stopsContainer__1XNWn"]//span[@class="BpkText_bpk-text__2NHsO BpkText_bpk-text--sm__345aT Duration_duration__1QA_S"]')
            transfer = t.read(f'(//div[@class="BpkTicket_bpk-ticket__Brlno BpkTicket_bpk-ticket--with-notches__2i2HX"])[{k+1}]//div//div//div//div[@class="LegDetails_container__11hQT TicketBody_leg__1_ia3"][{i+1}]//div//div[@class="LegInfo_stopsContainer__1XNWn"]//div//span')
            print(transfer)
            if transfer == 'Direct':
                transfer_plc = ''
            elif transfer == '1 stop':
                transfer_plc = t.read(f'(//div[@class="BpkTicket_bpk-ticket__Brlno BpkTicket_bpk-ticket--with-notches__2i2HX"])[{k+1}]//div//div//div//div[@class="LegDetails_container__11hQT TicketBody_leg__1_ia3"][{i+1}]//div//div[@class="LegInfo_stopsContainer__1XNWn"]//div//div//span//span')
            elif transfer == '2 stops':
                transfer_plc1 = t.read(f'(//div[@class="BpkTicket_bpk-ticket__Brlno BpkTicket_bpk-ticket--with-notches__2i2HX"])[{k+1}]//div//div//div//div[@class="LegDetails_container__11hQT TicketBody_leg__1_ia3"][{i+1}]//div[@class="LegInfo_stopsContainer__1XNWn"]//div//div//span[1]//span')
                transfer_plc2 = t.read(f'(//div[@class="BpkTicket_bpk-ticket__Brlno BpkTicket_bpk-ticket--with-notches__2i2HX"])[{k + 1}]//div//div//div//div[@class="LegDetails_container__11hQT TicketBody_leg__1_ia3"][{i + 1}]//div[@class="LegInfo_stopsContainer__1XNWn"]//div//div//span[2]//span')
                transfer_plc = transfer_plc1 + ',' + transfer_plc2
            elif transfer == '3 stops':
                transfer_plc1 = t.read(
                    f'(//div[@class="BpkTicket_bpk-ticket__Brlno BpkTicket_bpk-ticket--with-notches__2i2HX"])[{k + 1}]//div//div//div//div[@class="LegDetails_container__11hQT TicketBody_leg__1_ia3"][{i + 1}]//div[@class="LegInfo_stopsContainer__1XNWn"]//div//div//span[1]//span')
                transfer_plc2 = t.read(
                    f'(//div[@class="BpkTicket_bpk-ticket__Brlno BpkTicket_bpk-ticket--with-notches__2i2HX"])[{k + 1}]//div//div//div//div[@class="LegDetails_container__11hQT TicketBody_leg__1_ia3"][{i + 1}]//div[@class="LegInfo_stopsContainer__1XNWn"]//div//div//span[2]//span')
                transfer_plc3 = t.read(
                    f'(//div[@class="BpkTicket_bpk-ticket__Brlno BpkTicket_bpk-ticket--with-notches__2i2HX"])[{k + 1}]//div//div//div//div[@class="LegDetails_container__11hQT TicketBody_leg__1_ia3"][{i + 1}]//div[@class="LegInfo_stopsContainer__1XNWn"]//div//div//span[3]//span')
                transfer_plc = transfer_plc1 + ',' + transfer_plc2 + ',' + transfer_plc3

            print(transfer_plc)
            ### Arrival Time plus 1 day check
            if t.present(f'(//div[@class="BpkTicket_bpk-ticket__Brlno BpkTicket_bpk-ticket--with-notches__2i2HX"])[{k+1}]//div//div//div//div[@class="LegDetails_container__11hQT TicketBody_leg__1_ia3"][{i+1}]//div//div[@class="LegInfo_routePartialArrive__ZsZxc"]//span//div//span[@class="BpkText_bpk-text__2NHsO BpkText_bpk-text--sm__345aT TimeWithOffsetTooltip_offsetTooltip__24Ffv"]'):
                date_pls = 1
            else:
                date_pls = 0

            ### Bound Check
            dep = t.read(
                f'(//div[@class="BpkTicket_bpk-ticket__Brlno BpkTicket_bpk-ticket--with-notches__2i2HX"])[{k+1}]//div//div//div//div[@class="LegDetails_container__11hQT TicketBody_leg__1_ia3"][{i+1}]//div//div[@class="LegInfo_routePartialDepart__37kr9"]//span//span[@class="BpkText_bpk-text__2NHsO BpkText_bpk-text--base__2vfTl LegInfo_routePartialCityTooltip__ZqOZK"]')
            arr = t.read(
                f'(//div[@class="BpkTicket_bpk-ticket__Brlno BpkTicket_bpk-ticket--with-notches__2i2HX"])[{k+1}]//div//div//div//div[@class="LegDetails_container__11hQT TicketBody_leg__1_ia3"][{i+1}]//div//div[@class="LegInfo_routePartialArrive__ZsZxc"]//span//span[@class="BpkText_bpk-text__2NHsO BpkText_bpk-text--base__2vfTl LegInfo_routePartialCityTooltip__ZqOZK"]')
            bound = dep + ' - ' + arr
            bound_lst.append(bound)

            time_lst.append(time_dep)
            date_time_dep = date[i] + ' ' + time_dep
            datetime_dep = datetime.strptime(date_time_dep, "%d/%m/%Y %H:%M")
            time_dep_lst.append(datetime_dep)
            date_time_arr = date[i] + ' ' + time_arr
            if date_pls == 0:
                datetime_arr = datetime.strptime(date_time_arr, "%d/%m/%Y %H:%M")
            else:
                datetime_arr = datetime.strptime(date_time_arr, "%d/%m/%Y %H:%M") + timedelta(days=1)
            time_arr_lst.append(datetime_arr)

            airline_lst.append(airline)
            dur_lst.append(dur)
            dur_ref.append(dur)
            time_arr_day = ''
            time_arr_day_lst.append(time_arr_day)
            transfer_lst.append(transfer)
            transfer_plc_lst.append(transfer_plc)
            leg_lst.append(leg)
            index_lst.append(ind)


        href_lst.append(t.url()[0:-2] + href)
        deal_lst.append(ind)
        details = {'Deal Index': index_lst, 'Flight Leg': leg_lst, 'Bound': bound_lst, 'Departure Time': time_dep_lst,
                   'Arrival Time': time_arr_lst, 'Duration': dur_lst, 'Transfer': transfer_lst,
                   'Transfer Place': transfer_plc_lst, 'Airline': airline_lst}
        details_lst.append(details)
    flight_info = [[] for _ in range(2)]

    main = {'Deal': deal_lst, 'Flight Info': flight_info, 'Price': price_lst, 'Hyperlink': href_lst, 'Details': details_lst}
    return main, time_lst, code_lst, dur_ref, ind
Beispiel #9
0
import tagui as t
'''
search in the F12, to locate the element: //input[@name="q"] or //input[@class="gLFyf gsfi"]
for multiple selection: t.read(//div[@class="r"])[0]/a/@href')

select by content: //h2[contains(.,"Selector")]

select by id:  //*[@id="abc"]

t.present() to check whether some element exist or not

chrome plugin: xpath helper

https://devhints.io/xpath

'''

#--------------demo 1 -----------------------------
'''
t.init()
t.url('https://google.com')
print("test_tagui ok!")

t.type('//input[@name="q"]', 'weather[enter]')


t.type('//input[@name="q"]', '[clear]')

temp = t.read('//span[@id="wob_pp"]')
'''
Beispiel #10
0
t.keyboard('[tab]')
t.dclick('//*[@id="TransactionHistoryFG.FROM_TXN_DATE"]')
t.keyboard('[clear]')
t.dclick('//*[@id="TransactionHistoryFG.FROM_TXN_DATE"]')
t.keyboard('[clear]')
t.dclick('//*[@id="TransactionHistoryFG.FROM_TXN_DATE"]')
t.keyboard('[clear]')
t.dclick('//*[@id="TransactionHistoryFG.FROM_TXN_DATE"]')
t.keyboard('[clear]')
t.dclick('//*[@id="TransactionHistoryFG.FROM_TXN_DATE"]')
t.keyboard('[clear]')
t.type('//*[@id="TransactionHistoryFG.FROM_TXN_DATE"]',sdate)
t.click('//*[@id="SEARCH"]')
t.wait(3)
check=0
if t.present('//*[@id="errorlink1"]/img')==True:
    check=1
t.select('//*[@id="TransactionHistoryFG.OUTFORMAT"]',"4")
t.click('//*[@id="okButton"]')
t.wait(10)
t.click('//*[@id="HREF_Logout"]')
t.wait(5)
t.close()

if check==0:
    t.init(visual_automation = True,chrome_browser = False)
    t.keyboard('[win]r')
    t.wait(4)
    t.keyboard(directory)
    t.wait(4)
    t.keyboard('[enter]')
Beispiel #11
0
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 22 21:25:07 2019

@author: avikr
"""

import tagui as t
import getpass
t.init(visual_automation = True, chrome_browser = True)
t.url('https://accounts.google.com/ServiceLogin/identifier?service=mail&passive=true&rm=false&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&ss=1&scc=1&ltmpl=default&ltmplcache=2&emr=1&osid=1&flowName=GlifWebSignIn&flowEntry=ServiceLogin')
t.wait(10)
if t.present('//*[@id="identifierId"]')==True:
    t.keyboard('[alt][tab]')
    t.wait(4)
    emailid=t.ask("Enter Email ID")
    t.wait(10)
    t.keyboard('[alt][tab]')
    t.wait(2)
    t.type('//*[@id="identifierId"]',emailid)
    t.wait(3)
    
    t.click('//*[@id="identifierNext"]/span/span')
    t.wait(3)
    t.keyboard('[alt][tab]')
    t.wait(4)
    password = getpass.getpass("Enter Password")
    t.wait(10)
    t.keyboard('[alt][tab]')
    t.wait(2)
    t.type('//*[@id="password"]/div[1]/div/div[1]/input',password)
def make_reservation(reservation_date,reservation_time,party_size,restaurant_name,first_name,last_name,email_address,phone_number):
    try:
        #Convert User Defined Values to System Usable Values
        reservation_day=reservation_date.split('/')[0]
        reservation_month =reservation_date.split('/')[1]
        reservation_month=int(reservation_month)-1
        reservation_year =reservation_date.split('/')[2]
        reservation_time_int=int(reservation_time)
        start_time_hr= reservation_time[:2]
        if reservation_time_int>1159:
            if start_time_hr!="12":
                start_time_hr=int(start_time_hr)-12
            start_time_option = str(start_time_hr)+":"+reservation_time[2:4]+" pm"
        else:
            start_time_option = str(start_time_hr)+":"+reservation_time[2:4]+" am"
            
        #Booking Parameters
        chope_url ='https://www.chope.co/singapore-restaurants/category/restaurant/'
        t.init()
        t.url(chope_url)
        t.wait(10)
        #Date Field
        t.click(f"(//span[contains(@class,'input-group-addon icon-calendar')])[1]")
        t.wait(7)
        boolean_flag=1
        while boolean_flag:
            if t.present(f"//td[@data-handler='selectDay'and @data-year='{reservation_year}' and @data-month='{reservation_month}']/a[text()='{reservation_day}']"):
                t.click(f"//td[@data-handler='selectDay'and @data-year='{reservation_year}' and @data-month='{reservation_month}']/a[text()='{reservation_day}']")
                boolean_flag=0
            else:
                t.click('//a[@title="Next"]')
        t.click(f"//td[@data-handler='selectDay'and @data-month='{reservation_month}']/a[text()='{reservation_day}']")
        #Time Field
        t.select(f"//select[contains(@id,'time-field')]",start_time_option)
        #Number of Diners Field
        t.click(f"(//span[contains(@class,'input-group-addon icon-person')])[1]")
        t.select(f"//select[contains(@id,'adults')]",party_size)
        #Restaurant Field
        t.type(f"//select[contains(@id,'sb-sel-restaurant')]",restaurant_name)
        t.click('//button[@id="btn-search"]')
        t.wait(5)
        
        #Secondary Page to Confirm Timing
        t.click(f"//a[contains(@rname,'{restaurant_name}') and text()='{start_time_option}']")
        t.wait(5)
        t.click(f"//input[@id='btn_sub' and @value='Book Now']")
        t.wait(5)
        
        #Booking Confirmation
        t.popup('https://book.chope.co/')
        #First Name
        t.type('//input[@id="forename"]',first_name)
        #Last Name
        t.type('//input[@id="surname"]',last_name)
        #Email
        t.type('//input[@id="email"]',email_address)
        #Phone Number
        t.type('//input[@id="telephone"]',phone_number)
        #Agree Terms & Conditions
        if t.present(f"//input[@name='agree_term_conditions']"):
            t.click(f"//input[@name='agree_term_conditions']")
        #Confirm Booking
        t.click(f"//button[@id='check_book_now']")
        t.wait(5)
        t.close()
        print('Success')
        schedule_reservation(reservation_date,reservation_time,party_size,restaurant_name,first_name,sample_restaurant_address)
        return 'Reservation Successful'
    except:
        print('Error')
        return 'Reservation Unsuccessful. Unforunately, the restaurant was not able to accomodate your reservation.'