Skip to content

Commit

Permalink
set execution time to later step
Browse files Browse the repository at this point in the history
  • Loading branch information
seblum committed Nov 3, 2023
1 parent 776fb63 commit 1356711
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-push-to-dockerhub_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: publish docker CD

env:
DOCKERREPO: seblum/octivbooker
TAG: v1.2.2
TAG: v1.3.0

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion slotBooker/poetry.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ RUN apt-get install -yqq unzip
# https://googlechromelabs.github.io/chrome-for-testing/#stable
ENV ChromedriverVersion="119.0.6045.105"
# $ChromedriverVersion
RUN wget -O /tmp/chromedriver.zip https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/119.0.6045.105/linux64/chromedriver-linux64.zip
RUN wget -O /tmp/chromedriver.zip https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/$ChromedriverVersion/linux64/chromedriver-linux64.zip
RUN unzip /tmp/chromedriver.zip chromedriver-linux64/chromedriver -d /usr/local/bin/

# set display port to avoid crash
Expand Down
2 changes: 1 addition & 1 deletion slotBooker/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "slotBooker"
version = "1.2.2"
version = "1.3.0"
description = ""
authors = ["Sebastian Blum <[email protected]>"]

Expand Down
6 changes: 3 additions & 3 deletions slotBooker/slotbooker/booker.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ def main(retry: int = 3):
)

close_driver(driver)
logging.info(f"OctivBooker succeeded | try: {count+1}")
logging.info(f"[{count+1}] OctivBooker succeeded")
count = 3
except SessionNotCreatedException:
logging.info(f"OctivBooker failed | TRY: {count+1}")
logging.info(f"[{count+1}] OctivBooker failed")
logging.info(f"! SessionNotCreatedException")
count += 1
continue
except NoSuchDriverException:
logging.info(f"OctivBooker failed | TRY: {count+1}")
logging.info(f"[{count+1}] OctivBooker failed")
logging.info(f"! NoSuchDriverException")
count += 1
continue
Expand Down
15 changes: 9 additions & 6 deletions slotBooker/slotbooker/ui_interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,14 @@ def __click_book_button(xpath_button_book: str) -> None:
"""
# Use execute_script() when another element is covering the element to be clicked
element = self.driver.find_element(By.XPATH, xpath_button_book)
self.driver.execute_script("arguments[0].click();", element)

while True:
if datetime.now().time().strftime("%H:%M:%S") >= self.execution_booking_time:
logging.info(f"| Executed at {datetime.now().time()}")
self.driver.execute_script("arguments[0].click();", element)
break



def __book_class_slot(button_xpath: str) -> bool:
"""
Expand All @@ -276,11 +283,7 @@ def __book_class_slot(button_xpath: str) -> bool:
"""
logging.info(f"| Booking {class_slot} at {time_slot}")

while True:
if datetime.now().time().strftime("%H:%M:%S") >= self.execution_booking_time:
logging.info(f"| Executed at {datetime.now().time()}")
__click_book_button(xpath_button_book=button_xpath)
break
__click_book_button(xpath_button_book=button_xpath)

# Check whether alert appears
alert_obj = alert_is_present(self.driver)
Expand Down

0 comments on commit 1356711

Please sign in to comment.