@@ -145,35 +145,19 @@ def verify_autofill_dropdown_all_fields(self, ccp: AutofillPopup):
145
145
self .double_click ("form-field" , labels = ["cc-csc" ])
146
146
ccp .ensure_autofill_dropdown_not_visible ()
147
147
148
- def verify_four_fields (
149
- self , ccp : AutofillPopup , credit_card_sample_data : CreditCardBase
148
+ def verify_credit_card_form_data (
149
+ self , credit_card_sample_data : CreditCardBase
150
150
) -> Autofill :
151
151
"""
152
- Verifies that after clicking the autofill panel the information is filled correctly.
152
+ Verifies that the information is filled correctly.
153
153
154
154
Attributes
155
155
----------
156
156
157
- ccp: CreditCardPopup
158
- The credit card popup object
159
-
160
157
credit_card_sample_data: CreditCardBase
161
158
The object that contains all the relevant information about the credit card autofill
162
159
"""
163
- self .double_click ("form-field" , labels = ["cc-name" ])
164
160
info_list = self .extract_credit_card_obj_into_list (credit_card_sample_data )
165
- # Click on popup form value with name only
166
- if self .sys_platform () == "Linux" :
167
- with self .driver .context (self .driver .CONTEXT_CHROME ):
168
- ccp .custom_wait (timeout = 30 , poll_frequency = 0.5 ).until (
169
- EC .element_to_be_clickable (
170
- ccp .get_selector (
171
- "select-form-option-by-value" , labels = [info_list [0 ]]
172
- )
173
- )
174
- )
175
- ccp .click_on ("select-form-option-by-value" , labels = [info_list [0 ]])
176
-
177
161
for i in range (len (info_list )):
178
162
self .element_attribute_contains (
179
163
"form-field" , "value" , info_list [i ], labels = [self .fields [i ]]
@@ -225,13 +209,19 @@ def update_field(
225
209
self .fill_input_element (ba , field , field_data )
226
210
self .click_form_button ("submit" )
227
211
228
- def press_autofill_panel (self , credit_card_popoup_obj : AutofillPopup ):
212
+ def press_autofill_panel (
213
+ self , autofill_popup : AutofillPopup , field : str = "cc-name"
214
+ ):
229
215
"""
230
216
Presses the autofill panel that pops up after you double-click an input field
217
+
218
+ Argument:
219
+ field: field to click to show autofill option.
231
220
"""
232
- self .double_click ("form-field" , labels = ["cc-name" ])
221
+ self .double_click ("form-field" , labels = [field ])
222
+ autofill_popup .ensure_autofill_dropdown_visible ()
233
223
with self .driver .context (self .driver .CONTEXT_CHROME ):
234
- credit_card_popoup_obj .get_element ("select-form-option" ).click ()
224
+ autofill_popup .get_element ("select-form-option" ).click ()
235
225
236
226
def update_credit_card_information (
237
227
self ,
@@ -244,7 +234,6 @@ def update_credit_card_information(
244
234
Updates the credit card based on field that is to be changed by first autofilling everything then updating
245
235
the field of choice then pressing submit and handling the popup.
246
236
"""
247
- self .press_autofill_panel (autofill_popup_obj )
248
237
self .update_field (field_name , field_data , autofill_popup_obj )
249
238
self .click_form_button ("submit" )
250
239
@@ -302,67 +291,39 @@ def verify_updated_information(
302
291
# updating the profile accordingly
303
292
self .update_credit_card_information (autofill_popup_obj , field_name , new_data )
304
293
305
- # verifying the correct data
306
- self .verify_four_fields (autofill_popup_obj , credit_card_sample_data )
307
- return self
308
-
309
- def update_cc_name (
310
- self ,
311
- util : Utilities ,
312
- credit_card_sample_data : CreditCardBase ,
313
- autofill_popup_obj : AutofillPopup ,
314
- ) -> Autofill :
315
- """
316
- Generates a new name, updates the credit card information in the form.
317
- """
318
- new_cc_name = util .fake_credit_card_data ().name
319
- credit_card_sample_data .name = new_cc_name
320
-
321
- self .verify_updated_information (
322
- autofill_popup_obj ,
323
- credit_card_sample_data ,
324
- "cc-name" ,
325
- credit_card_sample_data .name ,
326
- )
327
- return self
328
-
329
- def update_cc_exp_month (
330
- self ,
331
- util : Utilities ,
332
- credit_card_sample_data : CreditCardBase ,
333
- autofill_popup_obj : AutofillPopup ,
334
- ) -> Autofill :
335
- """
336
- Generates a new expiry month, updates the credit card information in the form.
337
- """
338
- new_cc_exp_month = util .fake_credit_card_data ().expiration_month
339
- credit_card_sample_data .expiration_month = new_cc_exp_month
294
+ # autofill data
295
+ self .press_autofill_panel (autofill_popup_obj )
340
296
341
- self .verify_updated_information (
342
- autofill_popup_obj ,
343
- credit_card_sample_data ,
344
- "cc-exp-month" ,
345
- credit_card_sample_data .expiration_month ,
346
- )
297
+ # verifying the correct data
298
+ self .verify_credit_card_form_data (credit_card_sample_data )
347
299
return self
348
300
349
- def update_cc_exp_year (
301
+ def update_cc (
350
302
self ,
351
303
util : Utilities ,
352
304
credit_card_sample_data : CreditCardBase ,
353
305
autofill_popup_obj : AutofillPopup ,
306
+ field : str ,
354
307
) -> Autofill :
355
308
"""
356
- Generates a new expiry year , updates the credit card information in the form.
309
+ Generates a new data for credit card according to field given , updates the credit card information in the form.
357
310
"""
358
- new_cc_exp_year = util .fake_credit_card_data ().expiration_year
359
- credit_card_sample_data .expiration_year = new_cc_exp_year
311
+ cc_mapping = {
312
+ "cc-name" : "name" ,
313
+ "cc-exp-month" : "expiration_month" ,
314
+ "cc-exp-year" : "expiration_year" ,
315
+ "cc-number" : "card_number" ,
316
+ }
317
+ new_cc_data = getattr (util .fake_credit_card_data (), cc_mapping [field ])
318
+ while new_cc_data == getattr (credit_card_sample_data , cc_mapping [field ]):
319
+ new_cc_data = getattr (util .fake_credit_card_data (), cc_mapping [field ])
320
+ setattr (credit_card_sample_data , cc_mapping [field ], new_cc_data )
360
321
361
322
self .verify_updated_information (
362
323
autofill_popup_obj ,
363
324
credit_card_sample_data ,
364
- "cc-exp-year" ,
365
- credit_card_sample_data . expiration_year ,
325
+ field ,
326
+ new_cc_data ,
366
327
)
367
328
return self
368
329
@@ -383,6 +344,21 @@ def verify_clear_form_all_fields(self, autofill_popup_obj: AutofillPopup):
383
344
self .double_click ("form-field" , labels = ["cc-csc" ])
384
345
autofill_popup_obj .ensure_autofill_dropdown_not_visible ()
385
346
347
+ def autofill_and_clear_all_fields (
348
+ self , autofill_popup : AutofillPopup , credit_card_data : CreditCardBase
349
+ ):
350
+ """
351
+ For each field select autofill option and clear.
352
+ """
353
+ for field in self .fields :
354
+ # press autofill panel for a field.
355
+ self .press_autofill_panel (autofill_popup , field )
356
+ # verify cc data in form.
357
+ self .verify_credit_card_form_data (credit_card_data )
358
+ # Clear the fields after verification
359
+ self .click_on ("form-field" , labels = [field ])
360
+ autofill_popup .click_clear_form_option ()
361
+
386
362
def verify_field_yellow_highlights (self , expected_highlighted_fields = None ):
387
363
"""
388
364
Reuses the common highlight-check method from the base class.
0 commit comments