Skip to content

Commit ef269cb

Browse files
Altering caledar picker util to work for all operating systems
1 parent 23405aa commit ef269cb

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

utils/calendar_picker.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from utils.date_time_utils import DateTimeUtils
33
from playwright.sync_api import Page, Locator
44
from pages.base_page import BasePage
5-
import logging
5+
from sys import platform
66

77

88
class CalendarPicker(BasePage):
@@ -36,7 +36,10 @@ def calendar_picker_ddmonyy(self, date: datetime, locator: Locator) -> None:
3636
date (datetime): The date we want to enter into the locator
3737
locator (Locator): The locator of the element in which we want to enter the date
3838
"""
39-
formatted_date = DateTimeUtils.format_date(date, "%#d %b %Y")
39+
if platform == "win32": # Windows
40+
formatted_date = DateTimeUtils.format_date(date, "%#d %b %Y")
41+
else: # Linux or Mac
42+
formatted_date = DateTimeUtils.format_date(date, "%-d %b %Y")
4043
locator.fill(formatted_date)
4144
locator.press("Enter")
4245

@@ -78,7 +81,10 @@ def select_day(self, date: datetime) -> None:
7881
This function is used by both the v1 and v2 calendar picker
7982
It extracts the day from the date and then selects that value in the calendar picker
8083
"""
81-
day_to_select = str(date.strftime("%#d"))
84+
if platform == "win32": # Windows
85+
day_to_select = str(date.strftime("%#d"))
86+
else: # Linux or Mac
87+
day_to_select = str(date.strftime("%-d"))
8288
number_of_cells_with_day = self.page.get_by_role(
8389
"cell", name=day_to_select
8490
).count()

0 commit comments

Comments
 (0)