Skip to content

Commit

Permalink
Corrected method to get radio button selection
Browse files Browse the repository at this point in the history
root authored and root committed Jan 17, 2025
1 parent f26942f commit 53675da
Showing 3 changed files with 31 additions and 13 deletions.
12 changes: 8 additions & 4 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -748,17 +748,21 @@ def start_recording_the_vaccine_for_new_patient(shared_data, new_patient_name, n

@then("the delivery team, vaccine and vaccine product selection should persist on the choose vaccine page")
def check_values_persist_on_choose_vaccine_screen(shared_data):
assert get_selected_delivery_team_radio_button_value() == shared_data["site"]
assert get_selected_delivery_team_radio_button_value_on_choose_vaccine_page() == shared_data["site"]
attach_screenshot("delivery_team_selection_is_persisted")
assert get_selected_vaccine_radio_button_value_on_choose_vaccine_page() == shared_data["chosen_vaccine"]
attach_screenshot("vaccine_selection_is_persisted")
assert get_selected_vaccine_product_radio_button_value_on_choose_vaccine_page() == shared_data["chosen_vaccine_type"]
attach_screenshot("vaccine_product_selection_is_persisted")

@then("the patient's eligibility, assessment date, legal mechanism, assessing clinician, assessment outcome selection must persist on the assessment screen")
def the_eligibility_values_should_persist(shared_data):
assert get_selected_delivery_team_radio_button_value() == shared_data["site"]
pass

@then("the patient's consent answer, consent given by, consenting clinician, selection must persist on the assessment screen")
def the_consent_values_should_persist(shared_data):
assert get_selected_delivery_team_radio_button_value() == shared_data["site"]
pass

@then("the patient's vaccinated answer, vaccine product, vaccinate date, care model, batch number, vaccinator should persist")
def the_vaccinated_values_should_persist(shared_data):
assert get_selected_delivery_team_radio_button_value() == shared_data["site"]
pass
7 changes: 4 additions & 3 deletions helpers/playwrightHelper.py
Original file line number Diff line number Diff line change
@@ -283,9 +283,10 @@ def get_checked_radio_button_text(self, name):
legend_selector = f'//legend[text()="{name}"]'
self.page.wait_for_selector(legend_selector, timeout=5000)

radio_group = self.page.query_selector(f'{legend_selector}/ancestor::fieldset//div[contains(@class, "nhsuk-radios")]')

selected_radio = radio_group.query_selector('input[type="radio"]:checked')
fieldset = self.page.query_selector(legend_selector).evaluate_handle(
'element => element.closest("fieldset")'
)
selected_radio = fieldset.query_selector('input[type="radio"]:checked')

if not selected_radio:
print("No radio button is selected.")
25 changes: 19 additions & 6 deletions pages/choose_vaccines_page.py
Original file line number Diff line number Diff line change
@@ -68,11 +68,24 @@ def click_continue_to_assess_patient_button():
wait_for_element_to_appear(CONTINUE_BUTTON)
find_element_and_perform_action(CONTINUE_BUTTON, "click")

def get_selected_delivery_team_radio_button_value():
return get_checked_radio_button_text("Delivery team")
def get_selected_delivery_team_radio_button_value_on_choose_vaccine_page():
selected_value = get_checked_radio_button_text("Delivery team")
if selected_value != "":
return selected_value
else:
print("No delivery team selection was made.")
return "Delivery team selection did not persist"

def get_selected_vaccine_radio_button_value():
return get_checked_radio_button_text("Vaccine")
def get_selected_vaccine_radio_button_value_on_choose_vaccine_page():
selected_value = get_checked_radio_button_text("Vaccine")
if selected_value != "":
return selected_value
else:
return "Vaccine selection did not persist"

def get_selected_vaccine_product_radio_button_value():
return get_checked_radio_button_text("Vaccine product")
def get_selected_vaccine_product_radio_button_value_on_choose_vaccine_page():
selected_value = get_checked_radio_button_text("Vaccine product")
if selected_value != "":
return selected_value
else:
return "Vaccine product selection did not persist"

0 comments on commit 53675da

Please sign in to comment.