Skip to content

Commit 7253cb2

Browse files
committed
Fixed failing test steps
1 parent a96aae1 commit 7253cb2

File tree

3 files changed

+53
-30
lines changed

3 files changed

+53
-30
lines changed

pages/call_and_recall/create_a_plan_page.py

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ def __init__(self, page: Page):
2626
)
2727
# Create A Plan Table Locators
2828
self.weekly_invitation_rate_field_on_table = self.page.locator(
29-
"#invitationRateField"
29+
"#invitationPlan > tbody > tr:nth-child(1) > td.input.border-right.dt-type-numeric > input"
3030
)
3131
self.invitations_sent_value = self.page.locator(
32-
"#invitationPlan > tbody > tr:nth-child(1) > td:nth-child(8)"
32+
"tbody tr:nth-child(1) td:nth-child(8)"
3333
)
34+
3435
self.resulting_position_value = self.page.locator(
3536
"#invitationPlan > tbody > tr:nth-child(1) > td:nth-child(9)"
3637
)
@@ -137,28 +138,42 @@ def verify_weekly_invitation_rate_for_weeks(
137138

138139
def increment_invitation_rate_and_verify_changes(self) -> None:
139140
"""
140-
Increments the invitation rate by 1, then verifies that both the 'Invitations Sent' and 'Resulting Position' have increased by 1.
141+
Increments the invitation rate by 1, then verifies that both the
142+
'Invitations Sent' has increased by 1 and 'Resulting Position' has decreased by 1.
141143
"""
142-
# Get the current value of the Weekly Invitation Rate field
143-
current_value = int(
144-
self.create_a_plan_table.get_cell_value("Invitation Rate", 0)
144+
# Capture initial values before any changes
145+
initial_invitations_sent = int(self.invitations_sent_value.inner_text().strip())
146+
initial_resulting_position = int(
147+
self.resulting_position_value.inner_text().strip()
148+
)
149+
150+
# Increment the invitation rate
151+
current_rate = int(
152+
self.create_a_plan_table.get_cell_value("Invitation Rate", 1)
153+
)
154+
new_rate = str(current_rate + 1)
155+
self.weekly_invitation_rate_field_on_table.fill(new_rate)
156+
self.page.keyboard.press("Tab")
157+
158+
# Wait dynamically for updates
159+
expect(self.invitations_sent_value).to_have_text(
160+
str(initial_invitations_sent + 1)
145161
)
146-
# Increments by 1, fills the field with the new value, and Tabs out of the field
147-
new_value = str(current_value + 1)
148-
locator = self.weekly_invitation_rate_field_on_table
149-
locator.fill(new_value)
150-
locator.press("Tab")
151-
152-
# Verifies 'Invitations Sent' has increased by 1
153-
initial_invitations_sent = int(self.invitations_sent_value.inner_text())
162+
expect(self.resulting_position_value).to_have_text(
163+
str(initial_resulting_position + 1)
164+
)
165+
166+
# Capture updated values
167+
updated_invitations_sent = int(self.invitations_sent_value.inner_text().strip())
168+
updated_resulting_position = int(
169+
self.resulting_position_value.inner_text().strip()
170+
)
171+
172+
# Assert changes
154173
assert (
155-
int(self.invitations_sent_value.inner_text())
156-
== initial_invitations_sent + 1
157-
), "Invitations Sent did not increase by 1."
174+
updated_invitations_sent == initial_invitations_sent + 1
175+
), f"Expected Invitations Sent to increase by 1. Was {initial_invitations_sent}, now {updated_invitations_sent}."
158176

159-
# Verifies 'Resulting Position' has increased by 1
160-
initial_resulting_position = int(self.resulting_position_value.inner_text())
161177
assert (
162-
int(self.resulting_position_value.inner_text())
163-
== initial_resulting_position - 1
164-
), "Resulting Position did not decrease by 1."
178+
updated_resulting_position == initial_resulting_position + 1
179+
), f"Expected Resulting Position to increase by 1. Was {initial_resulting_position}, now {updated_resulting_position}."

tests/regression/call_and_recall/test_create_a_plan_regression.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,9 @@ def test_create_a_plan_set_daily_rate(page: Page, general_properties: dict) -> N
5252
CreateAPlanPage(page).verify_weekly_invitation_rate_for_weeks(1, 50, "140")
5353

5454

55-
@pytest.mark.wip
5655
@pytest.mark.regression
5756
@pytest.mark.call_and_recall
58-
def test_create_invitation_plan_weekly_rate(
59-
page: Page, general_properties: dict
60-
) -> None:
57+
def test_create_a_plan_weekly_rate(page: Page, general_properties: dict) -> None:
6158
"""
6259
Verifies that a user can set a weekly invitation rate in Create a Plan.
6360
"""
@@ -89,7 +86,7 @@ def test_create_invitation_plan_weekly_rate(
8986

9087
@pytest.mark.regression
9188
@pytest.mark.call_and_recall
92-
def test_update_invitation_rate_weekly(page: Page, tests_properties: dict) -> None:
89+
def test_update_invitation_rate_weekly(page: Page, general_properties: dict) -> None:
9390
"""
9491
Verifies that a Hub Manager State Registered is able to update a weekly Invitation rate
9592
and the Cumulative 'Invitations sent' and 'Resulting Position' values are updated.
@@ -100,7 +97,7 @@ def test_update_invitation_rate_weekly(page: Page, tests_properties: dict) -> No
10097

10198
# And I click the link text "BCS001"
10299
InvitationsMonitoringPage(page).go_to_invitation_plan_page(
103-
tests_properties["screening_centre_code"]
100+
general_properties["screening_centre_code"]
104101
)
105102

106103
# And I click the "Create a Plan" button

utils/table_util.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,20 @@ def get_column_index(self, column_name: str) -> int:
4646
)
4747

4848
headers = header_row.locator("th")
49-
header_texts = headers.evaluate_all("ths => ths.map(th => th.innerText.trim())")
5049

50+
# Extract first-row headers (general headers)
51+
header_texts = headers.evaluate_all("ths => ths.map(th => th.innerText.trim())")
52+
print("First Row Headers Found:", header_texts)
53+
54+
# Extract detailed second-row headers if first-row headers seem generic
55+
second_row_headers = self.table.locator("thead tr:nth-child(2) th").evaluate_all(
56+
"ths => ths.map(th => th.innerText.trim())"
57+
)
58+
# Merge both lists: Prioritize second-row headers if available
59+
if second_row_headers:
60+
header_texts = second_row_headers
61+
62+
print("Second Row Headers Found:", header_texts)
5163
for index, header in enumerate(header_texts):
5264
if column_name.lower() in header.lower():
5365
return index + 1 # Convert to 1-based index
@@ -198,7 +210,6 @@ def get_full_table_with_headers(self) -> dict:
198210
full_results[row + 1] = self.get_row_data_with_headers(row)
199211
return full_results
200212

201-
202213
def get_cell_value(self, column_name: str, row_index: int) -> str:
203214
"""
204215
Retrieves the text value of a cell at the specified column(name) and row(index).

0 commit comments

Comments
 (0)