Skip to content

Commit 94ddcbf

Browse files
authored
Merge pull request #4 from ssspe/update_logging
Updated logging to look nicer
2 parents 67853a1 + da46ae0 commit 94ddcbf

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/dominos_orderer.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def change_crust(webdriver, crust):
3434
if const.CRUSTS[crust]:
3535
webdriver.find_element_by_xpath("//i[@class#'icon-chevron-right carousel-control-icon is-clickable']")
3636
webdriver.find_element_by_xpath(f"//p[contains(text(), '{crust}')]").click()
37+
logging.info(f" {crust}")
3738

3839

3940
def click_topping(webdriver, topping):
@@ -64,6 +65,7 @@ def customise_pizza(webdriver, pizza_index, pizza, resource_name):
6465
"""
6566

6667
is_customised = True
68+
logging.info(f"Adding pizza {pizza['name']}!")
6769

6870
webdriver.find_elements_by_xpath(f"//button[@resource-name='{resource_name}']")[
6971
pizza_index.index(pizza['name'])].click()
@@ -73,15 +75,17 @@ def customise_pizza(webdriver, pizza_index, pizza, resource_name):
7375
change_crust(webdriver, pizza['customisation']['crust'])
7476

7577
for topping in pizza['customisation']['extra']:
76-
if not click_topping(webdriver, topping):
77-
is_customised = False
78-
logging.info(f"Added {topping} to the pizza.")
79-
80-
for topping in pizza['customisation']['remove']:
81-
for clicks in range(2):
78+
if topping != "":
8279
if not click_topping(webdriver, topping):
8380
is_customised = False
84-
logging.info(f"Removed {topping} from the pizza.")
81+
logging.info(f" + {topping}")
82+
83+
for topping in pizza['customisation']['remove']:
84+
if topping != "":
85+
for clicks in range(2):
86+
if not click_topping(webdriver, topping):
87+
is_customised = False
88+
logging.info(f" - {topping}")
8589

8690
if not is_customised:
8791
error_restart(webdriver)
@@ -122,15 +126,14 @@ def process_pizza_json(webdriver):
122126
pizza_index = [pizza_text.text for pizza_text in pizzas]
123127

124128
if pizza['customise']:
125-
logging.info(f"Customizing pizza {pizza['name']}!")
126-
127129
if pizza['name'] in pizza_index:
128130
customise_pizza(webdriver, pizza_index, pizza, "Customise")
129131
scroll_to_top(webdriver) # Add to order is at the top of the page
130132
webdriver.find_element_by_id("add-to-order").click()
131133

132134
else:
133135
if pizza['name'] in pizza_index:
136+
logging.info(f"Adding pizza {pizza['name']}!")
134137
# Adding the pizza that is at the index of the pizza name to the basket
135138
webdriver.find_elements_by_xpath("//button[@resource-name='AddToBasket']")[
136139
pizza_index.index(pizza['name'])].click()
@@ -162,7 +165,6 @@ def process_pizza_json(webdriver):
162165
pizza_index = [pizza.text for pizza in pizzas]
163166

164167
if pizza['name'] in pizza_index:
165-
logging.info(f"Customizing pizza {pizza['name']}!")
166168
customise_pizza(webdriver, pizza_index, pizza, "Choose")
167169

168170
if first_half:

src/web_driver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ def scroll_to_top(webdriver):
6161
:param webdriver: The Selenium webdriver
6262
"""
6363
webdriver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + Keys.HOME)
64-
time.sleep(5) # Have to sleep to allow dominos server to catch up
64+
time.sleep(10) # Have to sleep to allow dominos server to catch up

0 commit comments

Comments
 (0)