1
+ import pytest
2
+ from selenium .webdriver import Firefox
3
+
4
+ from modules .browser_object_autofill_popup import AutofillPopup
5
+ from modules .page_object_about_pages import AboutConfig
6
+ from modules .page_object_autofill import AddressFill
7
+ from modules .page_object_prefs import AboutPrefs
8
+ from modules .util import Utilities , BrowserActions
9
+
10
+
11
+
12
+ @pytest .fixture ()
13
+ def test_case ():
14
+ return "2888701"
15
+
16
+
17
+ def test_demo_ad_address_data_captured_in_doorhanger_and_stored (driver : Firefox , region : str ):
18
+ """
19
+ C2888703 - Verify Address data are captured in the Capture Doorhanger and stored in about:preferences
20
+ """
21
+ # instantiate objects
22
+ address_autofill = AddressFill (driver )
23
+ address_autofill_popup = AutofillPopup (driver )
24
+ util = Utilities ()
25
+ about_config = AboutConfig (driver )
26
+ browser_action_obj = BrowserActions (driver )
27
+
28
+ # Change pref value of region
29
+ about_config .change_config_value ("browser.search.region" , region )
30
+
31
+ # create fake data and fill it in
32
+ address_autofill .open ()
33
+ address_autofill_data = util .fake_autofill_data (region )
34
+ address_autofill .save_information_basic (address_autofill_data )
35
+
36
+ # The "Save address?" doorhanger is displayed
37
+ address_autofill_popup .element_visible ("address-save-doorhanger" )
38
+
39
+ # containing Street Address field
40
+ expected_street_add = address_autofill_data .street_address
41
+ address_autofill_popup .element_has_text ("address-doorhanger-street" , expected_street_add )
42
+
43
+ # containing City field
44
+ expected_city = address_autofill_data .address_level_2
45
+ address_autofill_popup .element_has_text ("address-doorhanger-city" , expected_city )
46
+
47
+ # containing State/Province field
48
+ expected_state = address_autofill_data .address_level_1
49
+ address_autofill_popup .element_has_text ("address-doorhanger-state" , expected_state )
50
+
51
+ # containing Zip code field
52
+ expected_zip = address_autofill_data .postal_code
53
+ address_autofill_popup .element_has_text ("address-doorhanger-zip" , expected_zip )
54
+
55
+ # containing Country field
56
+ expected_country = address_autofill_data .country
57
+ address_autofill_popup .element_has_text ("address-doorhanger-country" , expected_country )
58
+
59
+ # Click the "Save" button
60
+ address_autofill_popup .click_doorhanger_button ("save" )
61
+
62
+ # Navigate to about:preferences#privacy => "Autofill" section
63
+ about_prefs = AboutPrefs (driver , category = "privacy" ).open ()
64
+ iframe = about_prefs .get_save_addresses_popup_iframe ()
65
+ browser_action_obj .switch_to_iframe_context (iframe )
66
+
67
+ # The address saved in step 2 is listed in the "Saved addresses" modal: Street, city, state, zip and country
68
+ elements = about_prefs .get_elements ("saved-addresses-values" )
69
+ expected_values = [expected_street_add , expected_city , expected_zip , expected_country ]
70
+ found_name_org = any (
71
+ all (value in element .text for value in expected_values )
72
+ for element in elements
73
+ )
74
+ assert (
75
+ found_name_org
76
+ ), "Street, city, state, zip or country were not found in any of the address entries!"
0 commit comments