Skip to content

Commit

Permalink
Merge pull request #5 from stivenramireza/release/0.0.2
Browse files Browse the repository at this point in the history
Release 0.0.2
  • Loading branch information
stivenramireza authored Mar 14, 2021
2 parents 1be0f2f + cd310f0 commit 6a61b5d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 20 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v0.0.1a
release_name: v0.0.1a
tag_name: v0.0.2
release_name: v0.0.2
body: |
Adding more seconds to WebDriverWait
Adding book_date as parameter
draft: false
prerelease: false

Expand Down
2 changes: 1 addition & 1 deletion __version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.0.1a'
__version__ = '0.0.2'
5 changes: 1 addition & 4 deletions smartfit_booking/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@

def get_current_date() -> str:
return datetime.now().strftime("%d/%m/%Y")

def search_current_date() -> str:
return datetime.now().strftime("%d%m%Y")


def convert_24_to_12_hour(time_value: str) -> str:
t = time.strptime(time_value, "%H:%M")
return time.strftime("%I:%M %p", t)
19 changes: 7 additions & 12 deletions smartfit_booking/website_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

from smartfit_booking.formatter import (
get_current_date,
search_current_date,
convert_24_to_12_hour
)

from smartfit_booking.formatter import convert_24_to_12_hour
from smartfit_booking.logger import logger

import time
Expand Down Expand Up @@ -40,7 +35,7 @@ def login_to_website(driver: object, website_url: str, username: str, password:
login_button = driver.find_element_by_class_name('MuiButton-label')
if login_button.text == 'INGRESAR':
login_button.click()
time.sleep(10)
time.sleep(20)
logger.info('Login to website has been successfully')
except Exception as error:
logger.error(f'Error to login to website: {error}')
Expand Down Expand Up @@ -88,18 +83,18 @@ def search_headquarter(driver: object, headquarter_name: str) -> None:
driver.quit()
raise

def book_hour(driver: object, desire_hour: str) -> None:
def book_hour(driver: object, desired_date: str, desired_hour: str) -> None:
try:
input_date = driver.find_element_by_id('date-local')
input_date.send_keys(Keys.CONTROL, 'a')
input_date.send_keys(search_current_date())
input_date.send_keys(''.join(desired_date.split('/')))
schedule_table = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.CLASS_NAME, 'MuiTable-root'))
)
hours = schedule_table.find_elements_by_tag_name('tr')
for hour in hours:
h = hour.find_element_by_class_name('MuiTableCell-root')
if h.text == desire_hour:
if h.text == desired_hour:
book_button = hour.find_element_by_class_name('MuiButton-label')
if book_button.text.startswith('RESERVAR'):
book_button.click()
Expand Down Expand Up @@ -155,13 +150,13 @@ def search_chat(driver: object, chat_name: str) -> None:
driver.quit()
raise

def send_message(driver: object, file_path: str, person_name: str, book_hour: str) -> None:
def send_message(driver: object, file_path: str, person_name: str, book_date: str, book_hour: str) -> None:
try:
# Send text
input_box = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.XPATH, '//div[@contenteditable="true"][@data-tab="6"]'))
)
input_box.send_keys(f'Código QR Reserva hoy {get_current_date()} a las {convert_24_to_12_hour(book_hour)} - {person_name}')
input_box.send_keys(f'Código QR Reserva {book_date} a las {convert_24_to_12_hour(book_hour)} - {person_name}')
input_box.send_keys(Keys.ENTER)

# Attach file
Expand Down

0 comments on commit 6a61b5d

Please sign in to comment.