def completar_horario(datos):
    dateBox = bt.wait_element_id('booking-date-input')
    time.sleep(2)
    bt.write_into(dateBox, datos['Date'])
    bt.write_into(bt.find_by_xpath('//*[@id="booking-start"]/input'),
                  datos['Starting Time'])
    bt.write_into(bt.find_by_xpath('//*[@id="booking-end"]/input'),
                  datos['Ending Time'])
def completar_confirmacion(datos):
    bt.click_element(bt.find_by_xpath('//*[@id="main-tabs"]/li[3]/a'))
    bt.write_into(bt.find_by_id("event-name"), datos['EID'])
    bt.select_in(bt.find_by_id("event-type"), "Workspace")
    bt.write_into(
        bt.find_by_xpath(
            '//*[@id="reservation-details-billing"]/div/div[2]/div/div[1]/div/div/input'
        ), "DS79400D")  #"DS79400D")
    bt.click_element(
        bt.find_by_xpath('//*[@id="details"]/div[3]/div/span[2]/button'))
    #time.sleep(2)
    pantalla_carga()
def completar_location(datos):
    bt.click_element(
        bt.find_by_xpath('//*[@id="location-filter-container"]/div[1]/div/a'))
    element = bt.wait_element_xpath(
        '//div[starts-with(@id, "filter-main")]/div[1]/div[2]/div/input')
    time.sleep(3)
    bt.write_into(element, datos['Location'])
    time.sleep(1)
    bt.click_element(
        bt.find_by_xpath(
            '//div[starts-with(@id, "filter-main")]/div[2]/div[1]/div/label/input'
        ))
    bt.click_element(
        bt.find_by_xpath('//*[@id="filterModal"]/div/div/div[3]/button[1]'))
    pantalla_carga()
def obtener_sala():
    sala = None
    tabla = bt.find_by_xpath('//*[@id="available-list"]/tbody')
    lista = bt.get_children_from("tr", tabla)
    timeout = 0

    while len(lista) < 1 and timeout < 3:
        #time.sleep(1)
        timeout = timeout + 1
        tabla = bt.find_by_xpath('//*[@id="available-list"]/tbody')
        lista = bt.get_children_from("tr", tabla)
        print(timeout)
    if len(lista) > 1:
        sala = lista[1]

    return sala
def goto_list():
    bt.click_element(bt.find_by_id("return-to-top"))
    time.sleep(1)
    bt.click_element(bt.find_by_xpath('//*[@id="result-tabs"]/li[1]/a'))

    pantalla_carga()
    bt.wait_invisible(bt.find_by_class('loading-animation'))
def agregar_sala(sala):
    btnAgregar = bt.find_by_class('add-to-cart', sala)
    bt.click_element(btnAgregar)
    bt.click_element(bt.find_by_xpath('//*[@id="setup--add-modal-save"]'))
    #bt.wait_element_id("toaster")
    esperar_agregada('selected-rooms-container', 'div')
    time.sleep(1)
def book_now():
    bt.load_site(config.urls['reservations'])
    #bt.wait_element_id("sidebar-wrapper")
    bt.wait_element_clickable(
        '//*[@id="templates-grid"]/div/div[1]/div[2]/button[1]')
    bt.click_element(
        bt.find_by_xpath(
            '//*[@id="templates-grid"]/div/div[1]/div[2]/button[1]'))
def completar_capacidad(datos):
    #loading_img = bt.find_by_id('page-loading-overlay')
    element = bt.wait_element_xpath(
        '//*[@id="filter-container"]/div[1]/div[3]/div[2]/input')
    bt.write_into(element, datos['People'])
    pantalla_carga()
    bt.click_element(
        bt.find_by_xpath('//*[@id="filter-container"]/div[2]/button'))
    pantalla_carga()