|
2 | 2 | from utils.date_time_utils import DateTimeUtils |
3 | 3 | from playwright.sync_api import Page, Locator |
4 | 4 | from pages.base_page import BasePage |
5 | | -import logging |
| 5 | +from sys import platform |
6 | 6 |
|
7 | 7 |
|
8 | 8 | class CalendarPicker(BasePage): |
@@ -36,7 +36,10 @@ def calendar_picker_ddmonyy(self, date: datetime, locator: Locator) -> None: |
36 | 36 | date (datetime): The date we want to enter into the locator |
37 | 37 | locator (Locator): The locator of the element in which we want to enter the date |
38 | 38 | """ |
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") |
40 | 43 | locator.fill(formatted_date) |
41 | 44 | locator.press("Enter") |
42 | 45 |
|
@@ -78,7 +81,10 @@ def select_day(self, date: datetime) -> None: |
78 | 81 | This function is used by both the v1 and v2 calendar picker |
79 | 82 | It extracts the day from the date and then selects that value in the calendar picker |
80 | 83 | """ |
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")) |
82 | 88 | number_of_cells_with_day = self.page.get_by_role( |
83 | 89 | "cell", name=day_to_select |
84 | 90 | ).count() |
|
0 commit comments