def test_can_add_another_email(self, mozwebqa): user = MockUser() home_pg = HomePage(mozwebqa) home_pg.go_to_home_page() bid_login = home_pg.click_sign_in() bid_login.sign_in_new_user(user['email'], user['password']) # Open restmail inbox, find the email inbox = RestmailInbox(user['email']) email = inbox.find_by_index(0) # Load the BrowserID link from the email in the browser mozwebqa.selenium.get(email.verify_user_link) from browserid.pages.webdriver.complete_registration import CompleteRegistration complete_registration = CompleteRegistration(mozwebqa.selenium, mozwebqa.timeout) # Check the message on the registration page reflects a successful registration! Assert.contains("Thank you for signing up with Persona.", complete_registration.thank_you) home_pg.wait_for_user_login() Assert.equal(home_pg.logged_in_user_email, user['email']) home_pg.click_logout() second_user = MockUser() bid_login = home_pg.click_sign_in(expect='returning') bid_login.sign_in_add_another_email(second_user['email']) # Open restmail inbox, find the email inbox = RestmailInbox(second_user['email']) email = inbox.find_by_index(0) # Load the BrowserID link from the email in the browser mozwebqa.selenium.get(email.add_email_address_link) from browserid.pages.webdriver.complete_registration import CompleteRegistration complete_registration = CompleteRegistration(mozwebqa.selenium, mozwebqa.timeout) home_pg.wait_for_user_login() Assert.equal(home_pg.logged_in_user_email, second_user['email']) home_pg.click_logout() bid_login = home_pg.click_sign_in(expect='returning') expected_emails = [user['email'], second_user['email']] Assert.equal(expected_emails, bid_login.emails) Assert.equal(second_user['email'], bid_login.selected_email)
def test_can_create_new_user_account(self, mozwebqa): user = MockUser() home_pg = HomePage(mozwebqa) home_pg.go_to_home_page() bid_login = home_pg.click_sign_in() bid_login.sign_in_new_user(user['email'], user['password']) # Open restmail inbox, find the email inbox = RestmailInbox(user['email']) email = inbox.find_by_sender('*****@*****.**') # Load the BrowserID link from the email in the browser mozwebqa.selenium.get(email.verify_user_link) from browserid.pages.webdriver.complete_registration import CompleteRegistration CompleteRegistration(mozwebqa.selenium, mozwebqa.timeout) home_pg.go_to_home_page() bid_login = home_pg.click_sign_in(expect='returning') Assert.equal(user['email'], bid_login.signed_in_email) bid_login.sign_in_returning_user() home_pg.wait_for_user_login() Assert.equal(home_pg.logged_in_user_email, user['email'])
def test_that_checks_the_addition_of_a_review(self, mozwebqa): # Step 1 - Login into Marketplace user = MockUser() home_page = Home(mozwebqa) home_page.go_to_homepage() home_page.create_new_user(user) home_page.login(user) Assert.true(home_page.is_the_current_page) # Step 2 - Search for the test app and go to its details page search_page = home_page.header.search(self.test_app) details_page = search_page.results[0].click_name() Assert.true(details_page.is_the_current_page) Assert.true(details_page.is_submit_review_link_visible) Assert.equal(details_page.submit_review_link, "Submit a Review") # Step 3 - Write a review body = 'Automatic app review by Selenium tests %s' % datetime.now() rating = random.randint(1, 5) add_review_page = details_page.click_submit_review() review_page = add_review_page.write_a_review(rating, body) # Step 4 - Check review Assert.true(review_page.is_success_message_visible) Assert.equal(review_page.success_message, "Your review was successfully added!") review = review_page.reviews[0] Assert.equal(review.rating, rating) Assert.equal(review.author, user.name) Assert.equal(review.text, body)
def test_that_purchases_an_app_without_pre_auth_and_requests_a_refund(self, mozwebqa): """Litmus 58166""" user = MockUser() home_page = Home(mozwebqa) home_page.go_to_homepage() home_page.create_new_user(user) home_page.login(user) Assert.true(home_page.is_the_current_page) search_page = home_page.header.search(self._app_name) Assert.true(search_page.is_the_current_page) Assert.not_equal("FREE", search_page.results[0].price) details_page = search_page.results[0].click_name() Assert.true(details_page.is_app_available_for_purchase) pre_aproval_region = details_page.click_purchase() paypal_frame = pre_aproval_region.click_one_time_payment() paypal_popup = paypal_frame.login_to_paypal() Assert.true(paypal_popup.is_user_logged_into_paypal) try: # From this point on we have payed for the app so we have to request a refund paypal_popup.click_pay() paypal_popup.close_paypal_popup() Assert.true(details_page.is_app_installing) except Exception as exception: Assert.fail(exception) finally: self.request_refund_procedure(mozwebqa, self._app_name)
def create_user(self): url = "http://personatestuser.org/email/" response = urllib2.urlopen(url).read() decode = json.loads(response) return MockUser(email=decode['email'], password=decode['pass'], name=decode['email'].split('@')[0])
def test_create_new_user(self, mozwebqa): user = MockUser() home_page = Home(mozwebqa) home_page.go_to_homepage() home_page.create_new_user(user) home_page.login(user) Assert.true(home_page.is_the_current_page) Assert.true(home_page.footer.is_user_logged_in)
def new_user(request, persona_test_user, api): user = MockUser(email=persona_test_user['email'], username=persona_test_user['email'].split('@')[0], password=persona_test_user['pass']) def fin(): api.delete_user(user) request.addfinalizer(fin) return user
def new_user(request): testuser = get_personatestuser() request.new_user = MockUser(email=testuser['email'], username=testuser['email'].split('@')[0], password=testuser['pass']) def fin(): # Delete user from application database after the test if request.new_user: mozwebqa = request.getfuncargvalue('mozwebqa') delete_user_from_database(mozwebqa, request.new_user) request.addfinalizer(fin) return request.new_user
def _login_to_consumer_pages(self, mozwebqa, user=None): """login to consumer pages using the provided user if the user is not provided a new one will be created""" home_page = Home(mozwebqa) home_page.go_to_homepage() if user is None: user = MockUser() home_page.create_new_user(user) home_page.login(user) return home_page, user
def test_email_required_error(self, mozwebqa): mock_user = MockUser() home_pg = HomePage(mozwebqa) home_pg.go_to_home_page() home_pg.personal_tools_region.click_log_in_or_create_account() create_account_pg = LogInOrCreateAccountPage(mozwebqa) create_account_pg.click_create_account_link() create_account_pg.create_user(mock_user['username'], mock_user['password'], mock_user['password'], '', mock_user['realname']) Assert.true(create_account_pg.is_error_message_present) Assert.true( create_account_pg.get_error_message_text.index('No email address'))
def _login_to_consumer_pages(self, mozwebqa, user=None): """login to consumer pages using the provided user if the user is not provided a new one will be created""" from pages.desktop.consumer_pages.home import Home home_page = Home(mozwebqa) home_page.go_to_homepage() if user == None: from mocks.mock_user import MockUser user = MockUser() home_page.create_new_user(user) home_page.login(user) return home_page, user
def test_passwords_mismatch_error(self, mozwebqa): mock_user = MockUser() home_pg = HomePage(mozwebqa) home_pg.go_to_home_page() home_pg.personal_tools_region.click_log_in_or_create_account() create_account_pg = LogInOrCreateAccountPage(mozwebqa) create_account_pg.click_create_account_link() create_account_pg.create_user(mock_user['username'], mock_user['password'], 'blah', mock_user['email'], mock_user['realname']) Assert.true(create_account_pg.is_error_message_present) Assert.true( create_account_pg.get_error_message_text.index( 'The passwords you entered do not match.'))
def test_create_valid_new_user(self, mozwebqa): mock_user = MockUser() home_pg = HomePage(mozwebqa) home_pg.go_to_home_page() home_pg.personal_tools_region.click_log_in_or_create_account() create_account_pg = LogInOrCreateAccountPage(mozwebqa) create_account_pg.click_create_account_link() create_account_pg.create_user(mock_user['username'], mock_user['password'], mock_user['password'], mock_user['email'], mock_user['realname']) Assert.equal(create_account_pg.get_user_created_message, 'Login successful') Assert.equal(create_account_pg.get_user_welcome_message, 'Welcome, ' + mock_user['username'] + '!')
def test_user_already_exists_error(self, mozwebqa): mock_user = MockUser() home_pg = HomePage(mozwebqa) home_pg.go_to_home_page() home_pg.personal_tools_region.click_log_in_or_create_account() create_account_pg = LogInOrCreateAccountPage(mozwebqa) create_account_pg.click_create_account_link() create_account_pg.create_user('gbh', mock_user['password'], mock_user['password'], mock_user['email'], mock_user['realname']) Assert.true(create_account_pg.is_error_message_present) Assert.true( create_account_pg.get_error_message_text.index( 'Username entered already in use. Please choose a different name.' ))
def test_valid_email_required_error(self, mozwebqa): mock_user = MockUser() home_pg = HomePage(mozwebqa) home_pg.go_to_home_page() home_pg.personal_tools_region.click_log_in_or_create_account() create_account_pg = LogInOrCreateAccountPage(mozwebqa) create_account_pg.click_create_account_link() create_account_pg.create_user(mock_user['username'], mock_user['password'], mock_user['password'], 'notValidEmail', mock_user['realname']) Assert.true(create_account_pg.is_error_message_present) Assert.true( create_account_pg.get_error_message_text.index( 'The email address cannot be accepted as ' 'it appears to have an invalid format. Please ' 'enter a well-formatted address or empty that field.'))
def test_can_create_new_user_account(self, mozwebqa): user = MockUser() home_pg = HomePage(mozwebqa) home_pg.go_to_home_page() bid_login = home_pg.click_sign_in() bid_login.sign_in_new_user(user['email'], user['password']) # Open restmail inbox, find the email inbox = RestmailInbox(user['email']) email = inbox.find_by_index(0) # Load the BrowserID link from the email in the browser from browserid.pages.complete_registration import CompleteRegistration complete_registration = CompleteRegistration(mozwebqa.selenium, mozwebqa.timeout, email.verify_user_link) Assert.equal(home_pg.logged_in_user_email, user['email'])
def test_editing_user_profile(self, mozwebqa): """Test for https://www.pivotaltracker.com/story/show/33709085""" user = MockUser() home_page = Home(mozwebqa) home_page.go_to_homepage() home_page.create_new_user(user) home_page.login(user) profile_page = home_page.footer.click_account_settings() _username = user['email'].split('@')[0] #Initial check Assert.equal(profile_page.browser_id_email, user['email']) Assert.equal(profile_page.username, _username) Assert.equal(profile_page.display_name, _username) #Data to submit. Username and Bio should be unique name = 'Napoleon' username = _username[::-1] location = 'Saint Helena' occupation = 'Emperor of the French' homepage = 'https://mozilla.org/' bio = 'Unique bio for %s' % _username profile_page.edit_display_name(name) profile_page.edit_username(username) profile_page.edit_location(location) profile_page.edit_occupation(occupation) profile_page.edit_homepage(homepage) profile_page.edit_bio(bio) profile_page.check_email_me_checkbox() profile_page.save_changes() Assert.equal(profile_page.notification_text, 'Profile Updated') Assert.equal(profile_page.display_name, name) Assert.equal(profile_page.username, username) Assert.equal(profile_page.location, location) Assert.equal(profile_page.occupation, occupation) Assert.equal(profile_page.homepage, homepage) Assert.equal(profile_page.bio, bio) Assert.false(profile_page.is_email_me_checked)
def existing_user(request): testuser = get_personatestuser() mozwebqa = request.getfuncargvalue('mozwebqa') username = testuser['email'].split('@')[0] request.existing_user = create_user_in_database( mozwebqa, MockUser(email=testuser['email'], username=username, password=testuser['pass'], profile={ 'name': 'mozwebqa_testuser', 'username': username, 'privacy_policy_accepted': True })) def fin(): # Delete user from application database after the test if request.existing_user: delete_user_from_database(mozwebqa, request.existing_user) request.addfinalizer(fin) return request.existing_user
def test_can_change_user_password(self, mozwebqa): user = MockUser() home_pg = HomePage(mozwebqa) home_pg.go_to_home_page() bid_login = home_pg.click_sign_in() bid_login.sign_in_new_user(user['email'], user['password']) # Open restmail inbox, find the email inbox = RestmailInbox(user['email']) email = inbox.find_by_index(0) # Load the BrowserID link from the email in the browser from browserid.pages.complete_registration import CompleteRegistration CompleteRegistration(mozwebqa.selenium, mozwebqa.timeout, email.verify_user_link) mozwebqa.selenium.get(self._persona_server_url(mozwebqa)) from browserid.pages.account_manager import AccountManager account_manager = AccountManager(mozwebqa.selenium, mozwebqa.timeout) Assert.contains(user['email'], account_manager.emails) account_manager.click_edit_password() account_manager.old_password = user['password'] new_password = "******" account_manager.new_password = new_password account_manager.click_password_done() account_manager.click_sign_out() mozwebqa.selenium.execute_script('localStorage.clear()') home_pg.go_to_home_page() bid_login = home_pg.click_sign_in() bid_login.sign_in(user['email'], new_password) home_pg.wait_for_user_login() Assert.true(home_pg.is_logged_in)
def test_that_checks_the_deletion_of_a_review(self, mozwebqa): """ https://moztrap.mozilla.org/manage/case/648/ """ # Step 1 - Login into Marketplace user = MockUser() home_page = Home(mozwebqa) home_page.go_to_homepage() home_page.create_new_user(user) home_page.login(user) Assert.true(home_page.is_the_current_page) # Step 2 - Search for the test app and go to its details page search_page = home_page.header.search(self.test_app) details_page = search_page.results[0].click_name() Assert.true(details_page.is_the_current_page) Assert.true(details_page.is_submit_review_link_visible) # Step 3 - Write a review body = 'Automatic app review by Selenium tests %s' % datetime.now() rating = random.randint(1, 5) add_review_page = details_page.click_submit_review() reviews_page = add_review_page.write_a_review(rating, body) # Step 4 - Check review Assert.true(reviews_page.is_success_message_visible) # Step 5 - Delete review review = reviews_page.reviews[0] review.delete() Assert.true(reviews_page.is_success_message_visible) Assert.equal(reviews_page.success_message, "Your review was successfully deleted!") Assert.false(review.is_review_visible)
def create_user(self): url = "http://personatestuser.org/email/" response = requests.get(url) decode = response.json() return MockUser(email=decode['email'], password=decode['pass'], name=decode['email'].split('@')[0])
def get_user(self, mozwebqa, user='******'): acct = mozwebqa.credentials[user] return MockUser(email=acct['email'], password=acct['password'], name=acct['email'].split('@')[0])
def create_new_user(self, mozwebqa): acct = FxATestAccount(mozwebqa.base_url).create_account() return MockUser(email=acct.email, password=acct.password, name=acct.email.split('@')[0])