@@ -18,6 +18,41 @@ def __init__(self, page: Page):
1818 self .update_subject_data_button = self .page .get_by_role (
1919 "button" , name = "Update Subject Data"
2020 )
21+ self .temporary_address_show_link = (
22+ self .page .locator ("font" )
23+ .filter (has_text = "Temporary Address show" )
24+ .get_by_role ("link" )
25+ )
26+ self .temporary_address_valid_from_calendar_button = self .page .locator (
27+ "#UI_SUBJECT_ALT_FROM_0_LinkOrButton"
28+ )
29+ self .temporary_address_valid_to_calendar_button = self .page .locator (
30+ "#UI_SUBJECT_ALT_TO_0_LinkOrButton"
31+ )
32+ self .temporary_address_valid_from_text_box = self .page .get_by_role (
33+ "textbox" , name = "Valid from"
34+ )
35+ self .temporary_address_valid_to_text_box = self .page .get_by_role (
36+ "textbox" , name = "Valid to"
37+ )
38+ self .temporary_address_address_line_1 = self .page .locator (
39+ "#UI_SUBJECT_ALT_ADDR1_0"
40+ )
41+ self .temporary_address_address_line_2 = self .page .locator (
42+ "#UI_SUBJECT_ALT_ADDR2_0"
43+ )
44+ self .temporary_address_address_line_3 = self .page .locator (
45+ "#UI_SUBJECT_ALT_ADDR3_0"
46+ )
47+ self .temporary_address_address_line_4 = self .page .locator (
48+ "#UI_SUBJECT_ALT_ADDR4_0"
49+ )
50+ self .temporary_address_address_line_5 = self .page .locator (
51+ "#UI_SUBJECT_ALT_ADDR5_0"
52+ )
53+ self .temporary_address_postcode = self .page .locator (
54+ "#UI_SUBJECT_ALT_POSTCODE_0"
55+ )
2156
2257 def is_forename_filled (self ) -> bool :
2358 """
@@ -99,3 +134,53 @@ def get_dob_field_value(self) -> str:
99134 str: The subject's date of birth as a string
100135 """
101136 return self .dob_field .input_value ()
137+
138+ def update_temporary_address (self , dict : dict ) -> None :
139+ """
140+ Updates the temporary address fields with the provided dictionary values.
141+ Args:
142+ dict (dict): A dictionary containing the temporary address details.
143+ Expected keys: 'valid_from', 'valid_to', 'address_line_1',
144+ 'address_line_2', 'address_line_3', 'address_line_4', 'address_line_5'.
145+ """
146+ # Click the link to show the temporary address fields
147+ if self .temporary_address_show_link .is_visible ():
148+ # If the link is visible, click it to show the temporary address fields
149+ self .click (self .temporary_address_show_link )
150+
151+ # Update the valid from date
152+ if "valid_from" in dict :
153+ if dict ["valid_from" ] is None :
154+ self .temporary_address_valid_from_text_box .fill ("" )
155+ else :
156+ CalendarPicker (self .page ).calendar_picker_ddmmyyyy (
157+ dict ["valid_from" ], self .temporary_address_valid_from_text_box
158+ )
159+
160+ # Update the valid to date
161+ if "valid_to" in dict :
162+ if dict ["valid_to" ] is None :
163+ self .temporary_address_valid_to_text_box .fill ("" )
164+ else :
165+ CalendarPicker (self .page ).calendar_picker_ddmmyyyy (
166+ dict ["valid_to" ], self .temporary_address_valid_to_text_box
167+ )
168+
169+ # Fill in the address lines
170+ if "address_line_1" in dict :
171+ self .temporary_address_address_line_1 .fill (dict ["address_line_1" ])
172+ if "address_line_2" in dict :
173+ self .temporary_address_address_line_2 .fill (dict ["address_line_2" ])
174+ if "address_line_3" in dict :
175+ self .temporary_address_address_line_3 .fill (dict ["address_line_3" ])
176+ if "address_line_4" in dict :
177+ self .temporary_address_address_line_4 .fill (dict ["address_line_4" ])
178+ if "address_line_5" in dict :
179+ self .temporary_address_address_line_5 .fill (dict ["address_line_5" ])
180+
181+ # Fill in the postcode
182+ if "postcode" in dict :
183+ self .temporary_address_postcode .fill (dict ["postcode" ])
184+
185+ # Click the update subject data button to save changes
186+ self .update_subject_data_button .click ()
0 commit comments