def test_create_and_delete_collection(self, base_url, selenium, existing_user): home_page = Home(base_url, selenium) collections_page = home_page.header.site_navigation_menu( 'Collections').click() create_collection_page = collections_page.click_create_collection_button( ) home_page.login(existing_user['email'], existing_user['password']) collection_uuid = uuid.uuid4().hex collection_time = repr(time.time()) collection_name = collection_uuid[:30 - len(collection_time ):] + collection_time create_collection_page.type_name(collection_name) create_collection_page.type_description(collection_name) collection = create_collection_page.click_create_collection() assert 'Collection created!' == collection.notification assert collection_name == collection.collection_name collection.delete() user_collections = collection.delete_confirmation() if user_collections.has_no_results: pass else: for collection_element in range( len(user_collections.collections) ): # If the condition is satisfied, iterate through the collections items on the page assert collection_name not in user_collections.collections[ collection_element].text # Check for each collection that the name is not the same as the deleted collections name
def test_create_collection(self, mozwebqa): home_page = Home(mozwebqa) collections_page = home_page.header.site_navigation_menu( 'Collections').click() create_collection_page = collections_page.click_create_collection_button( ) home_page.login('browserID') collection_name = 'collection timestamp %s' % time.time() create_collection_page.type_name(collection_name) create_collection_page.type_description(collection_name) collection = create_collection_page.click_create_collection() Assert.equal(collection.notification, 'Collection created!') Assert.equal(collection.collection_name, collection_name) collection.delete() user_collections = collection.delete_confirmation() if len(user_collections.collections) > 0: for collection_element in range( len(user_collections.collections) ): # If the condition is satisfied, iterate through the collections items on the page Assert.true( collection_name not in user_collections.collections[collection_element].text ) # Check for each collection that the name is not the same as the deleted collections name else: Assert.equal( user_collections.collection_text, 'No collections found.' ) # It means the collection has been deleted and we test for that
def test_that_one_star_rating_increments(self, mozwebqa): """ Test for Litmus 22916. https://litmus.mozilla.org/show_test.cgi?id=22916 """ # Step 1 - Login into AMO home_page = Home(mozwebqa) home_page.login("browserID") Assert.true(home_page.header.is_user_logged_in) # Step 2 - Go to add-ons listing page sorted by rating extensions_home_page = home_page.click_to_explore('Top Rated') # Step 3 - Pick an addon with no reviews extensions_home_page.paginator.click_last_page() addon = extensions_home_page.extensions[-1] # the last one is without rating details_page = addon.click() # Step 4 - Click on the "Write review" button write_review_block = details_page.click_to_write_review() # Step 5 - Add review with 1-star rating body = 'Automatic addon review by Selenium tests' write_review_block.enter_review_with_text(body) write_review_block.set_review_rating(1) view_reviews = write_review_block.click_to_save_review() # Step 6 - Ensure rating increased by one view_reviews.breadcrumbs[2].click() details_page = Details(mozwebqa) new_rating_counter = details_page.get_rating_counter(1) Assert.equal(new_rating_counter, 1)
def test_create_collection(self, mozwebqa): home_page = Home(mozwebqa) collections_page = home_page.header.site_navigation_menu("Collections").click() create_collection_page = collections_page.click_create_collection_button() home_page.login("browserID") random_name = "random number following%s" % random.randrange(1, 100) create_collection_page.type_name(random_name) create_collection_page.type_description(random_name) collection = create_collection_page.click_create_collection() Assert.equal(collection.notification, "Collection created!") Assert.equal(collection.collection_name, random_name) collection.delete() user_collections = collection.delete_confirmation() if len(user_collections.collections) > 0: for collection_element in range( len(user_collections.collections) ): # If the condition is satisfied, iterate through the collections items on the page Assert.true( random_name not in user_collections.collections[collection_element].text ) # Check for each collection that the name is not the same as the deleted collections name else: Assert.equal( user_collections.collection_text, "No collections found." ) # It means the collection has been deleted and we test for that
def test_that_new_review_is_saved(self, mozwebqa, existing_user): # Step 1 - Login into AMO home_page = Home(mozwebqa) home_page.login(existing_user['email'], existing_user['password']) assert home_page.is_the_current_page assert home_page.header.is_user_logged_in # Step 2 - Load any addon detail page details_page = Details(mozwebqa, 'Memchaser') # Step 3 - Click on "Write review" button write_review_block = details_page.click_to_write_review() # Step 4 - Write a review body = 'Automatic addon review by Selenium tests %s' % datetime.now() write_review_block.enter_review_with_text(body) write_review_block.set_review_rating(1) review_page = write_review_block.click_to_save_review() # Step 5 - Assert review review = review_page.reviews[0] assert review.rating == 1 assert review.author == existing_user['name'] date = datetime.now(timezone('US/Pacific')).strftime("%B %d, %Y") # there are no leading zero-signs on day so we need to remove them too expected_date = date.replace(' 0', ' ') assert review.date == expected_date, 'Date of review does not match the expected value. ' 'Expected: "%s" but found "%s"' % (expected_date, review.date)
def test_that_new_review_is_saved(self, mozwebqa): """ Test for Litmus 22921. https://litmus.mozilla.org/show_test.cgi?id=22921 """ # Step 1 - Login into AMO home_page = Home(mozwebqa) home_page.login("browserID") Assert.true(home_page.is_the_current_page) Assert.true(home_page.header.is_user_logged_in) # Step 2 - Load any addon detail page details_page = Details(mozwebqa, 'Adblock Plus') # Step 3 - Click on "Write review" button write_review_block = details_page.click_to_write_review() # Step 4 - Write a review body = 'Automatic addon review by Selenium tests %s' % datetime.now() write_review_block.enter_review_with_text(body) write_review_block.set_review_rating(1) review_page = write_review_block.click_to_save_review() # Step 5 - Assert review review = review_page.reviews[0] Assert.equal(review.rating, 1) Assert.equal(review.author, mozwebqa.credentials['default']['name']) date = datetime.now().strftime("%B %d, %Y") # there are no leading zero-signs on day so we need to remove them too date = date.replace(' 0', ' ') Assert.equal(review.date, date) Assert.equal(review.text, body)
def test_hide_email_checkbox_works(self, mozwebqa): home_page = Home(mozwebqa) home_page.login("browserID") Assert.true(home_page.is_the_current_page) Assert.true(home_page.header.is_user_logged_in) view_profile_page = home_page.header.click_view_profile() initial_state = view_profile_page.is_email_field_present edit_profile_page = home_page.header.click_edit_profile() edit_profile_page.change_hide_email_state() edit_profile_page.click_update_account() view_profile_page = home_page.header.click_view_profile() final_state = view_profile_page.is_email_field_present try: Assert.not_equal(initial_state, final_state, 'The initial and final states are the same. The profile change failed.') if final_state is True: credentials = mozwebqa.credentials['default'] Assert.equal(credentials['email'], view_profile_page.email_value, 'Actual value is not equal with the expected one.') except Exception as exception: Assert.fail(exception.msg) finally: if initial_state != final_state: edit_profile_page = home_page.header.click_edit_profile() edit_profile_page.change_hide_email_state() edit_profile_page.click_update_account() view_profile_page = home_page.header.click_view_profile() Assert.equal(view_profile_page.is_email_field_present, initial_state, 'Could not restore profile to initial state.')
def test_user_can_login_and_logout(self, base_url, selenium, user): home_page = Home(base_url, selenium) home_page.login(user['email'], user['password']) assert home_page.is_the_current_page assert home_page.header.is_user_logged_in home_page.header.click_logout() assert not home_page.header.is_user_logged_in
def test_user_can_login_and_logout(self, mozwebqa, existing_user): home_page = Home(mozwebqa) home_page.login(existing_user['email'], existing_user['password']) assert home_page.is_the_current_page assert home_page.header.is_user_logged_in home_page.header.click_logout() assert not home_page.header.is_user_logged_in
def test_user_can_login_and_logout(self, base_url, selenium, existing_user): home_page = Home(base_url, selenium) home_page.login(existing_user['email'], existing_user['password']) assert home_page.is_the_current_page assert home_page.header.is_user_logged_in home_page.header.click_logout() assert not home_page.header.is_user_logged_in
def test_user_can_access_the_view_profile_page(self, base_url, selenium, existing_user): home_page = Home(base_url, selenium) home_page.login(existing_user['email'], existing_user['password']) assert home_page.is_the_current_page assert home_page.header.is_user_logged_in view_profile_page = home_page.header.click_view_profile() assert 'About me' == view_profile_page.about_me
def test_user_can_access_the_view_profile_page(self, mozwebqa, existing_user): home_page = Home(mozwebqa) home_page.login(existing_user['email'], existing_user['password']) assert home_page.is_the_current_page assert home_page.header.is_user_logged_in view_profile_page = home_page.header.click_view_profile() assert 'About me' == view_profile_page.about_me
def test_user_can_login_and_logout(self, mozwebqa, existing_user): home_page = Home(mozwebqa) home_page.login(existing_user['email'], existing_user['password']) assert home_page.is_the_current_page assert home_page.header.is_user_logged_in home_page.header.click_logout() assert home_page.header.is_user_logged_in is False
def test_user_my_collections_page(self, mozwebqa, existing_user): home_page = Home(mozwebqa) home_page.login(existing_user['email'], existing_user['password']) assert home_page.is_the_current_page assert home_page.header.is_user_logged_in my_collections_page = home_page.header.click_my_collections() assert 'Collections by %s :: Add-ons for Firefox' % existing_user['name'] == my_collections_page.page_title assert 'Collections by %s' % existing_user['name'] == my_collections_page.my_collections_header_text
def test_user_can_access_the_view_profile_page(self, mozwebqa, existing_user): home_page = Home(mozwebqa) home_page.login(existing_user['email'], existing_user['password']) assert home_page.is_the_current_page assert home_page.header.is_user_logged_in view_profile_page = home_page.header.click_view_profile() assert view_profile_page.about_me == 'About me'
def test_user_can_access_the_view_profile_page(self, mozwebqa, existing_user): home_page = Home(mozwebqa) home_page.login(existing_user['email'], existing_user['password']) Assert.true(home_page.is_the_current_page) Assert.true(home_page.header.is_user_logged_in) view_profile_page = home_page.header.click_view_profile() Assert.equal(view_profile_page.about_me, 'About me')
def test_user_can_login_and_logout_using_browser_id(self, mozwebqa): home_page = Home(mozwebqa) home_page.login("browserID") Assert.true(home_page.is_the_current_page) Assert.true(home_page.header.is_user_logged_in) home_page.header.click_logout() Assert.false(home_page.header.is_user_logged_in)
def test_user_can_access_the_view_profile_page(self, mozwebqa): home_page = Home(mozwebqa) home_page.login() Assert.true(home_page.is_the_current_page) Assert.true(home_page.header.is_user_logged_in) view_profile_page = home_page.header.click_view_profile() Assert.equal(view_profile_page.about_me, 'About me')
def test_the_logout_link_for_logged_in_users(self, mozwebqa): home_page = Home(mozwebqa) home_page.login() Assert.true(home_page.is_the_current_page) Assert.true(home_page.header.is_user_logged_in) discovery_pane = DiscoveryPane(mozwebqa, self.basepath(mozwebqa)) home_page = discovery_pane.click_logout() Assert.true(home_page.is_the_current_page) Assert.false(home_page.header.is_user_logged_in)
def test_the_logout_link_for_logged_in_users(self, mozwebqa, existing_user): home_page = Home(mozwebqa) home_page.login(existing_user['email'], existing_user['password']) assert home_page.is_the_current_page assert home_page.header.is_user_logged_in discovery_pane = DiscoveryPane(mozwebqa, self.basepath(mozwebqa)) home_page = discovery_pane.click_logout() assert home_page.is_the_current_page assert not home_page.header.is_user_logged_in
def test_the_logout_link_for_logged_in_users(self, base_url, services_base_url, selenium, existing_user): home_page = Home(base_url, selenium) home_page.login(existing_user['email'], existing_user['password']) assert home_page.is_the_current_page assert home_page.header.is_user_logged_in discovery_pane = DiscoveryPane(services_base_url, selenium, self.basepath(selenium)) home_page = discovery_pane.click_logout() assert home_page.is_the_current_page assert not home_page.header.is_user_logged_in
def test_user_my_collections_page(self, base_url, selenium, existing_user): home_page = Home(base_url, selenium) home_page.login(existing_user['email'], existing_user['password']) assert home_page.is_the_current_page assert home_page.header.is_user_logged_in my_collections_page = home_page.header.click_my_collections() assert 'Collections by %s :: Add-ons for Firefox' % existing_user[ 'name'] == my_collections_page.page_title assert 'Collections by %s' % existing_user[ 'name'] == my_collections_page.my_collections_header_text
def test_user_my_collections_page(self, mozwebqa): home_page = Home(mozwebqa) home_page.login() Assert.true(home_page.is_the_current_page) Assert.true(home_page.header.is_user_logged_in) username = mozwebqa.credentials['default']['name'] my_collections_page = home_page.header.click_my_collections() Assert.equal('Collections by %s :: Add-ons for Firefox' % username, home_page.page_title) Assert.equal('Collections by %s' % username, my_collections_page.my_collections_header_text)
def test_that_add_a_review_button_works(self, base_url, selenium, existing_user): # Step 1: Addons Home Page loads and Addons Details loads home_page = Home(base_url, selenium) # Step 2:user logs in to submit a review home_page.login(existing_user['email'], existing_user['password']) assert home_page.header.is_user_logged_in # Step 3: user loads an addon details page and clicks write a review button details_page = Details(base_url, selenium, 'Firebug') review_box = details_page.click_to_write_review() assert review_box.is_review_box_visible
def test_that_add_a_review_button_works(self, mozwebqa): #Step 1: Addons Home Page loads and Addons Details loads home_page = Home(mozwebqa) #Step 2:user logs in to submit a review home_page.login() Assert.true(home_page.header.is_user_logged_in) #Step 3: user loads an addon details page and clicks write a review button details_page = Details(mozwebqa, 'Firebug') review_box = details_page.click_to_write_review() Assert.true(review_box.is_review_box_visible)
def test_that_add_a_review_button_works(self, mozwebqa, existing_user): # Step 1: Addons Home Page loads and Addons Details loads home_page = Home(mozwebqa) # Step 2:user logs in to submit a review home_page.login(existing_user['email'], existing_user['password']) assert home_page.header.is_user_logged_in # Step 3: user loads an addon details page and clicks write a review button details_page = Details(mozwebqa, 'Firebug') review_box = details_page.click_to_write_review() assert review_box.is_review_box_visible
def test_web_extension_submission(self, addon, base_url, selenium, user): home_page = Home(base_url, selenium) home_page.login(user['email'], user['password']) agreement_page = home_page.header.click_submit_a_new_addon() distribution_page = agreement_page.accept_agreement() distribution_page.select_on_this_site() upload_page = distribution_page.click_continue() upload_page.upload_addon(addon) details_page = upload_page.click_continue() details_page.select_misc_category() details_page.select_mpl_license() finish_page = details_page.click_submit_addon() assert finish_page.is_manage_listing_displayed
def test_user_can_access_the_edit_profile_page(self, mozwebqa, existing_user): home_page = Home(mozwebqa) home_page.login(existing_user['email'], existing_user['password']) assert home_page.is_the_current_page assert home_page.header.is_user_logged_in amo_user_edit_page = home_page.header.click_edit_profile() assert '/users/edit' in amo_user_edit_page.get_url_current_page() assert amo_user_edit_page.is_the_current_page assert 'My Account' == amo_user_edit_page.account_header_text assert 'Profile' == amo_user_edit_page.profile_header_text assert 'Details' == amo_user_edit_page.details_header_text assert 'Notifications' == amo_user_edit_page.notification_header_text
def test_user_can_access_the_edit_profile_page(self, base_url, selenium, existing_user): home_page = Home(base_url, selenium) home_page.login(existing_user['email'], existing_user['password']) assert home_page.is_the_current_page assert home_page.header.is_user_logged_in amo_user_edit_page = home_page.header.click_edit_profile() assert '/users/edit' in amo_user_edit_page.get_url_current_page() assert amo_user_edit_page.is_the_current_page assert 'My Account' == amo_user_edit_page.account_header_text assert 'Profile' == amo_user_edit_page.profile_header_text assert 'Details' == amo_user_edit_page.details_header_text assert 'Notifications' == amo_user_edit_page.notification_header_text
def test_user_can_access_the_view_profile_page(self, mozwebqa): """ Test for litmus 15400. https://litmus.mozilla.org/show_test.cgi?id=15400 """ home_page = Home(mozwebqa) home_page.login("browserID") Assert.true(home_page.is_the_current_page) Assert.true(home_page.header.is_user_logged_in) view_profile_page = home_page.header.click_view_profile() Assert.equal(view_profile_page.about_me, 'About me')
def test_user_can_login_and_logout_using_browser_id(self, mozwebqa): """ Test for Litmus 7857 and 4859. https://litmus.mozilla.org/show_test.cgi?id=7857 https://litmus.mozilla.org/show_test.cgi?id=4859 """ home_page = Home(mozwebqa) home_page.login("browserID") Assert.true(home_page.is_the_current_page) Assert.true(home_page.header.is_user_logged_in) home_page.header.click_logout() Assert.false(home_page.header.is_user_logged_in)
def test_the_logout_link_for_logged_in_users(self, mozwebqa): """ Test for Litmus 15110. https://litmus.mozilla.org/show_test.cgi?id=15110 """ home_page = Home(mozwebqa) home_page.login() Assert.true(home_page.is_the_current_page) Assert.true(home_page.header.is_user_logged_in) discovery_pane = DiscoveryPane(mozwebqa, self.basepath(mozwebqa)) home_page = discovery_pane.click_logout() Assert.true(home_page.is_the_current_page) Assert.false(home_page.header.is_user_logged_in)
def test_user_can_access_the_edit_profile_page(self, mozwebqa, existing_user): home_page = Home(mozwebqa) home_page.login(existing_user['email'], existing_user['password']) assert home_page.is_the_current_page assert home_page.header.is_user_logged_in amo_user_edit_page = home_page.header.click_edit_profile() assert "/users/edit" in amo_user_edit_page.get_url_current_page() assert amo_user_edit_page.is_the_current_page assert "My Account" == amo_user_edit_page.account_header_text assert "Profile" == amo_user_edit_page.profile_header_text assert "Details" == amo_user_edit_page.details_header_text assert "Notifications" == amo_user_edit_page.notification_header_text
def test_user_can_access_the_edit_profile_page(self, mozwebqa, existing_user): home_page = Home(mozwebqa) home_page.login(existing_user['email'], existing_user['password']) Assert.true(home_page.is_the_current_page) Assert.true(home_page.header.is_user_logged_in) amo_user_edit_page = home_page.header.click_edit_profile() Assert.contains("/users/edit", amo_user_edit_page.get_url_current_page()) Assert.true(amo_user_edit_page.is_the_current_page) Assert.equal("My Account", amo_user_edit_page.account_header_text) Assert.equal("Profile", amo_user_edit_page.profile_header_text) Assert.equal("Details", amo_user_edit_page.details_header_text) Assert.equal("Notifications", amo_user_edit_page.notification_header_text)
def test_user_can_access_the_edit_profile_page(self, mozwebqa): home_page = Home(mozwebqa) home_page.login() Assert.true(home_page.is_the_current_page) Assert.true(home_page.header.is_user_logged_in) amo_user_edit_page = home_page.header.click_edit_profile() Assert.contains("/users/edit", amo_user_edit_page.get_url_current_page()) Assert.true(amo_user_edit_page.is_the_current_page) Assert.equal("My Account", amo_user_edit_page.account_header_text) Assert.equal("Profile", amo_user_edit_page.profile_header_text) Assert.equal("Details", amo_user_edit_page.details_header_text) Assert.equal("Notifications", amo_user_edit_page.notification_header_text)
def test_user_my_collections_page(self, mozwebqa): """ Test for litmus 15401. https://litmus.mozilla.org/show_test.cgi?searchType=by_id&id=15401 """ home_page = Home(mozwebqa) home_page.login() Assert.true(home_page.is_the_current_page) Assert.true(home_page.header.is_user_logged_in) username = mozwebqa.credentials['default']['name'] my_collections_page = home_page.header.click_my_collections() Assert.equal('Collections by %s :: Add-ons for Firefox' % username, home_page.page_title) Assert.equal('Collections by %s' % username, my_collections_page.my_collections_header_text)
def test_user_my_collections_page(self, mozwebqa): """ Test for litmus 15401. https://litmus.mozilla.org/show_test.cgi?searchType=by_id&id=15401 """ home_page = Home(mozwebqa) home_page.login("browserID") Assert.true(home_page.is_the_current_page) Assert.true(home_page.header.is_user_logged_in) username = mozwebqa.credentials['default']['name'] my_collections_page = home_page.header.click_my_collections() Assert.equal('Collections by %s :: Add-ons for Firefox' % username, home_page.page_title) Assert.equal('Collections by %s' % username, my_collections_page.my_collections_header_text)
def test_hide_email_checkbox_works(self, mozwebqa, existing_user): home_page = Home(mozwebqa) home_page.login(existing_user['email'], existing_user['password']) assert home_page.is_the_current_page assert home_page.header.is_user_logged_in view_profile_page = home_page.header.click_view_profile() initial_state = view_profile_page.is_email_field_present edit_profile_page = home_page.header.click_edit_profile() edit_profile_page.change_hide_email_state() edit_profile_page.click_update_account() view_profile_page = home_page.header.click_view_profile() final_state = view_profile_page.is_email_field_present assert not initial_state == final_state, 'The initial and final states are the same. The profile change failed.'
def test_that_add_a_review_button_works(self, mozwebqa): """ Test for Litmus 25729. https://litmus.mozilla.org/show_test.cgi?searchType=by_id&id=25729 """ #Step 1: Addons Home Page loads and Addons Details loads home_page = Home(mozwebqa) #Step 2:user logs in to submit a review home_page.login() Assert.true(home_page.header.is_user_logged_in) #Step 3: user loads an addon details page and clicks write a review button details_page = Details(mozwebqa, 'Firebug') review_box = details_page.click_to_write_review() Assert.true(review_box.is_review_box_visible)
def test_that_add_a_review_button_works(self, mozwebqa): """ Test for Litmus 25729. https://litmus.mozilla.org/show_test.cgi?searchType=by_id&id=25729 """ #Step 1: Addons Home Page loads and Addons Details loads home_page = Home(mozwebqa) #Step 2:user logs in to submit a review home_page.login("browserID") Assert.true(home_page.header.is_user_logged_in) #Step 3: user loads an addon details page and clicks write a review button details_page = Details(mozwebqa, 'Firebug') review_box = details_page.click_to_write_review() Assert.true(review_box.is_review_box_visible)
def test_user_can_update_profile_information_in_account_settings_page( self, mozwebqa): """ Test for Litmus 11563. https://litmus.mozilla.org/show_test.cgi?id=11563 """ home_page = Home(mozwebqa) home_page.login(method="browserID", user="******") Assert.true(home_page.is_the_current_page) Assert.true(home_page.header.is_user_logged_in) user_edit_page = home_page.header.click_edit_profile() Assert.true(user_edit_page.is_the_current_page) # save initial values to restore them after the test is finished fields_no = len(user_edit_page.profile_fields) - 1 initial_value = [None] * fields_no random_name = "test%s" % random.randrange(1, 100) # enter new values for i in range(0, fields_no): initial_value[i] = deepcopy( user_edit_page.profile_fields[i].field_value) user_edit_page.profile_fields[i].clear_field() user_edit_page.profile_fields[i].type_value(random_name) user_edit_page.click_update_account() Assert.equal(user_edit_page.update_message, "Profile Updated") # using try finally to ensure that the initial values are restore even if the Asserts fail. try: for i in range(0, fields_no): Assert.contains(random_name, user_edit_page.profile_fields[i].field_value) except Exception as exception: Assert.fail(exception.msg) finally: # restore initial values for i in range(0, fields_no): user_edit_page.profile_fields[i].clear_field() user_edit_page.profile_fields[i].type_value(initial_value[i]) user_edit_page.click_update_account()
def test_user_can_update_profile_information_in_account_settings_page( self, mozwebqa, editable_user): home_page = Home(mozwebqa) home_page.login(editable_user['email'], editable_user['password']) assert home_page.is_the_current_page assert home_page.header.is_user_logged_in user_edit_page = home_page.header.click_edit_profile() assert user_edit_page.is_the_current_page # save initial values to restore them after the test is finished fields_no = len(user_edit_page.profile_fields) initial_value = [None] * fields_no random_name = "webqa.account%s" % random.randrange(1, 100) # enter new values for i in range(0, fields_no): if user_edit_page.profile_fields[i].is_field_editable: initial_value[i] = deepcopy( user_edit_page.profile_fields[i].field_value) user_edit_page.profile_fields[i].clear_field() user_edit_page.profile_fields[i].type_value(random_name) user_edit_page.click_update_account() assert 'Profile Updated' == user_edit_page.update_message # using try finally to ensure that the initial values are restore even if the Asserts fail. try: for i in range(0, fields_no): if user_edit_page.profile_fields[i].is_field_editable: assert random_name in user_edit_page.profile_fields[ i].field_value except Exception as exception: raise AssertionError(exception.msg) finally: # restore initial values for i in range(0, fields_no): if user_edit_page.profile_fields[i].is_field_editable: user_edit_page.profile_fields[i].clear_field() user_edit_page.profile_fields[i].type_value( initial_value[i]) user_edit_page.click_update_account()
def test_hide_email_checkbox_works(self, mozwebqa): home_page = Home(mozwebqa) home_page.login() Assert.true(home_page.is_the_current_page) Assert.true(home_page.header.is_user_logged_in) view_profile_page = home_page.header.click_view_profile() initial_state = view_profile_page.is_email_field_present edit_profile_page = home_page.header.click_edit_profile() edit_profile_page.change_hide_email_state() edit_profile_page.click_update_account() view_profile_page = home_page.header.click_view_profile() final_state = view_profile_page.is_email_field_present Assert.not_equal(initial_state, final_state, 'The initial and final states are the same. The profile change failed.')
def test_web_extension_submission(self, base_url, selenium, user): home_page = Home(base_url, selenium) home_page.login(user['email'], user['password']) submit_page = home_page.header.click_submit_a_new_addon() path = generate() submit_page.upload_addon(path) submit_page.continue_to_step_three() submit_page.click_misc_option() submit_page.continue_to_step_four() submit_page.continue_to_step_five() submit_page.click_mpl_license() submit_page.continue_to_step_six() submit_page.click_review_button() assert submit_page.is_next_steps_present
def test_that_user_can_contribute_to_an_addon(self, mozwebqa, existing_user, paypal_user): """Test that checks the Contribute button for an add-on using PayPal.""" addon_page = Home(mozwebqa) addon_page.login(existing_user['email'], existing_user['password']) assert addon_page.is_the_current_page assert addon_page.header.is_user_logged_in addon_page = Details(mozwebqa, self.addon_name) contribution_snippet = addon_page.click_contribute_button() paypal_frame = contribution_snippet.click_make_contribution_button() assert addon_page.is_paypal_login_dialog_visible payment_popup = paypal_frame.login_to_paypal(paypal_user['email'], paypal_user['password']) assert payment_popup.is_user_logged_into_paypal payment_popup.click_pay() assert payment_popup.is_payment_successful payment_popup.close_paypal_popup() assert addon_page.is_the_current_page
def test_user_my_favorites_page(self, base_url, selenium, existing_user): home_page = Home(base_url, selenium) home_page.login(existing_user['email'], existing_user['password']) assert home_page.is_the_current_page assert home_page.header.is_user_logged_in # mark an add-on as favorite if there is none if not home_page.header.is_my_favorites_menu_present: details_page = Details(base_url, selenium, 'Firebug') # sometimes the call to is_my_favorites_menu_present lies # and clicking the add to favorites locator when it's already favorited # makes things worse if not details_page.is_addon_marked_as_favorite: details_page.click_add_to_favorites() assert details_page.is_addon_marked_as_favorite home_page = Home(base_url, selenium) my_favorites_page = home_page.header.click_my_favorites() assert my_favorites_page.is_the_current_page assert 'My Favorite Add-ons' == my_favorites_page.my_favorites_header_text
def test_hide_email_checkbox_works(self, mozwebqa): home_page = Home(mozwebqa) home_page.login("browserID") Assert.true(home_page.is_the_current_page) Assert.true(home_page.header.is_user_logged_in) view_profile_page = home_page.header.click_view_profile() initial_state = view_profile_page.is_email_field_present edit_profile_page = home_page.header.click_edit_profile() edit_profile_page.change_hide_email_state() edit_profile_page.click_update_account() view_profile_page = home_page.header.click_view_profile() final_state = view_profile_page.is_email_field_present try: Assert.not_equal( initial_state, final_state, 'The initial and final states are the same. The profile change failed.' ) if final_state is True: credentials = mozwebqa.credentials['default'] Assert.equal( credentials['email'], view_profile_page.email_value, 'Actual value is not equal with the expected one.') except Exception as exception: Assert.fail(exception.msg) finally: if initial_state != final_state: edit_profile_page = home_page.header.click_edit_profile() edit_profile_page.change_hide_email_state() edit_profile_page.click_update_account() view_profile_page = home_page.header.click_view_profile() Assert.equal(view_profile_page.is_email_field_present, initial_state, 'Could not restore profile to initial state.')