def test_marketplace_login_from_app_details_page(self): account = self.create_firefox_account() marketplace = Marketplace(self.marionette, self.MARKETPLACE_DEV_NAME) home_page = marketplace.launch() app_name = home_page.first_free_app['name'] details_page = home_page.navigate_to_app(app_name) ff_accounts = details_page.tap_write_review(logged_in=False) ff_accounts.login(account.email, account.password) # switch back to Marketplace marketplace.switch_to_marketplace_frame() details_page.wait_for_login_success_notification() current_time = str(time.time()).split('.')[0] rating = random.randint(1, 5) body = 'This is a test %s' % current_time review_page = AddReview(self.marionette) details_page = review_page.write_a_review(rating, body) details_page.wait_for_review_posted_notification() # Check if review was added correctly self.assertEqual(details_page.first_review_rating, rating) self.assertEqual(details_page.first_review_body, body)
def test_purchase_app(self): APP_NAME = 'Test Zippy With Me' PIN = '1234' username = self.testvars['marketplace']['username'] password = self.testvars['marketplace']['password'] if self.apps.is_app_installed(APP_NAME): self.apps.uninstall(APP_NAME) marketplace = Marketplace(self.marionette, self.MARKETPLACE_DEV_NAME) marketplace.launch() marketplace.login(username, password) marketplace.set_region('United States') details_page = marketplace.navigate_to_app(APP_NAME) payment = details_page.tap_purchase_button() payment.create_pin(PIN) payment.wait_for_buy_app_section_displayed() self.assertIn(APP_NAME, payment.app_name) payment.tap_buy_button() # Confirm the installation and wait for the app icon to be present confirm_install = ConfirmInstall(self.marionette) confirm_install.tap_confirm() self.assertEqual('%s installed' % APP_NAME, marketplace.install_notification_message) marketplace.switch_to_marketplace_frame() self.assertEqual('Launch', details_page.install_button_text)
def test_login_marketplace(self): # https://moztrap.mozilla.org/manage/case/4134/ marketplace = Marketplace(self.marionette, self.MARKETPLACE_DEV_NAME) home_page = marketplace.launch() account = self.create_firefox_account() home_page.login(account.email, account.password) # switch back to Marketplace marketplace.switch_to_marketplace_frame() # wait for the expected notification, and for user to be signed in home_page.wait_for_login_success_notification() settings = home_page.show_menu().tap_settings() settings.wait_for_sign_out_button() # Verify that user is logged in self.assertEqual(account.email, settings.email) # Sign out, which should return to the Marketplace home screen settings.tap_sign_out() # Verify that user is signed out settings.wait_for_sign_in_displayed()
def test_forgot_pin(self): old_pin = '1234' new_pin = '1111' account = self.create_firefox_account() marketplace = Marketplace(self.marionette, self.MARKETPLACE_DEV_NAME) home_page = marketplace.launch() home_page.login(account.email, account.password) search_results_page = self.tap_install_button_of_first_paid_app() payment = Payment(self.marionette) payment.create_pin(old_pin) payment.wait_for_buy_app_section_displayed() self.assertIn(self.app_name, payment.app_name) payment.tap_cancel_button() search_results_page.wait_for_payment_cancelled_notification() search_results_page.search_results[0].tap_install_button() payment.switch_to_payment_frame() payment.tap_forgot_pin() payment.tap_reset_button() ff_accounts = FirefoxAccounts(self.marionette) ff_accounts.login(account.email, account.password) payment.switch_to_payment_frame() payment.enter_pin(new_pin) payment.confirm_pin(new_pin) payment.wait_for_buy_app_section_displayed() self.assertIn(self.app_name, payment.app_name)
def test_purchase_app(self): pin = '1234' account = self.create_firefox_account() marketplace = Marketplace(self.marionette, self.MARKETPLACE_DEV_NAME) home_page = marketplace.launch() home_page.login(account.email, account.password) search_results_page = self.tap_install_button_of_first_paid_app() payment = Payment(self.marionette) payment.create_pin(pin) payment.wait_for_buy_app_section_displayed() self.assertIn(self.app_name, payment.app_name) payment.tap_buy_button() self.wait_for_downloads_to_finish() # Confirm the installation and wait for the app icon to be present confirm_install = ConfirmInstall(self.marionette) confirm_install.tap_confirm() self.assertEqual('%s installed' % self.app_name, search_results_page.install_notification_message) marketplace.switch_to_marketplace_frame() app = search_results_page.search_results[0] self.assertEqual('Open app', app.install_button_text)
def test_search_and_install_app(self): marketplace = Marketplace(self.marionette, self.MARKETPLACE_DEV_NAME) marketplace.launch() self.app_name = marketplace.popular_apps[0].name app_author = marketplace.popular_apps[0].author results = marketplace.search(self.app_name) self.assertGreater(len(results.search_results), 0, 'No results found.') first_result = results.search_results[0] self.assertEquals(first_result.name, self.app_name, 'First app has the wrong name.') self.assertEquals(first_result.author, app_author, 'First app has the wrong author.') # Find and click the install button to the install the web app self.assertEquals(first_result.install_button_text, 'Free', 'Incorrect button label.') first_result.tap_install_button() self.confirm_installation() self.APP_INSTALLED = True # Press Home button self.marionette.execute_script("window.wrappedJSObject.dispatchEvent(new Event('home'));") # Check that the icon of the app is on the homescreen homescreen = Homescreen(self.marionette) self.apps.switch_to_displayed_app() self.assertTrue(homescreen.is_app_installed(self.app_name))
def test_marketplace_without_connectivity(self): marketplace = Marketplace(self.marionette, self.MARKETPLACE_DEV_NAME) marketplace.launch() self.apps.switch_to_displayed_app() self.assertEqual(marketplace.error_title_text, self.expected_error_title) self.assertEqual(marketplace.error_message_text, self.expected_error_message)
def test_add_review(self): marketplace = Marketplace(self.marionette, 'Marketplace dev') marketplace.launch() # Sign in settings = marketplace.tap_settings() persona = settings.tap_sign_in() persona.login(self.user.email, self.user.password) self.marionette.switch_to_frame() marketplace.launch() settings.wait_for_sign_out_button() # Search and select app results = marketplace.search('SoundCloud') self.assertGreater(len(results.search_results), 0, 'No results found.') details_page = results.search_results[0].tap_app() # Setting your default values for review current_time = str(time.time()).split('.')[0] rating = random.randint(1, 5) body = 'This is a test %s' % current_time # Adding the review review_box = details_page.tap_write_review() review_box.write_a_review(rating, body) marketplace.wait_for_notification_message_displayed() # Check if review was added correctly self.assertEqual(marketplace.notification_message, "Your review was posted") self.assertEqual(details_page.first_review_rating, rating) self.assertEqual(details_page.first_review_body, body)
def test_marketplace_change_region_anonymous(self): marketplace = Marketplace(self.marionette, 'Marketplace Dev') marketplace.launch() settings = marketplace.tap_settings() # change region settings.select_region(self._REGION) # save changes settings.tap_save_changes() # wait for the changes to be saved marketplace.wait_for_notification_message_displayed() self.assertEqual(marketplace.notification_message, 'Settings saved') # go to home marketplace.tap_back() # go back to settings settings = marketplace.tap_settings() # check if the region is same as changed before self.assertEqual(settings.region, self._REGION)
def test_marketplace_feedback_anonymous(self): test_comment = 'This is a test comment.' marketplace = Marketplace(self.marionette, self.MARKETPLACE_DEV_NAME) home_page = marketplace.launch() feedback = home_page.show_menu().tap_feedback() feedback.enter_feedback(test_comment) feedback.submit_feedback() feedback.wait_for_feedback_submitted_notification()
def test_search_paid_app(self): marketplace = Marketplace(self.marionette, self.MARKETPLACE_DEV_NAME) home_page = marketplace.launch() home_page.set_region('United States') app = home_page.search(':paid').search_results[0] saved_price = app.install_button_text details_page = app.tap_app() self.assertEqual(saved_price, details_page.install_button_text)
def test_marketplace_feedback_user(self): test_comment = 'This is a test comment.' account = self.create_firefox_account() marketplace = Marketplace(self.marionette, self.MARKETPLACE_DEV_NAME) home_page = marketplace.launch() home_page.login(account.email, account.password) feedback = home_page.show_menu().tap_feedback() feedback.enter_feedback(test_comment) feedback.submit_feedback() feedback.wait_for_feedback_submitted_notification()
def test_create_confirm_pin(self): pin = '1234' account = self.create_firefox_account() marketplace = Marketplace(self.marionette, self.MARKETPLACE_DEV_NAME) home_page = marketplace.launch() home_page.login(account.email, account.password) self.tap_install_button_of_first_paid_app() payment = Payment(self.marionette) payment.create_pin(pin) payment.wait_for_buy_app_section_displayed() self.assertIn(self.app_name, payment.app_name)
def test_search_and_install_app(self): marketplace = Marketplace(self.marionette, self.MARKETPLACE_DEV_NAME) home_page = marketplace.launch() # Find a free app to install app = home_page.first_free_app self.app_name = app["name"] if self.apps.is_app_installed(self.app_name): raise Exception("The app %s is already installed." % self.app_name) marketplace.switch_to_marketplace_frame() results_page = home_page.search(self.app_name) results = results_page.search_results self.assertGreater(len(results), 0, "No results found.") first_result = results[0] self.assertEquals(first_result.name, self.app_name, "First app has the wrong name.") self.assertEquals( first_result.author, app["author"], "First app has the wrong author. Found %s but expected %s." % (first_result.author, app["author"]), ) # Find and click the install button to the install the web app self.assertEquals(first_result.install_button_text, "Install for free", "Incorrect button label.") first_result.tap_install_button() self.wait_for_downloads_to_finish() # Confirm the installation and wait for the app icon to be present confirm_install = ConfirmInstall(self.marionette) confirm_install.tap_confirm() self.assertEqual("%s installed" % self.app_name, results_page.install_notification_message) # Press Home button self.device.touch_home_button() # Check that the icon of the app is on the homescreen homescreen = Homescreen(self.marionette) self.apps.switch_to_displayed_app() self.assertTrue(homescreen.is_app_installed(self.app_name))
def test_open_website(self): marketplace = Marketplace(self.marionette, self.MARKETPLACE_DEV_NAME) home_page = marketplace.launch() new_apps = home_page.show_menu().tap_new() new_apps.select_content('websites') details_page = new_apps.app_list[0].tap_app() result_href = details_page.website_href details_page.tap_open_website_button() browser = Browser(self.marionette) browser.apps.switch_to_displayed_app() self.assertEqual(result_href, browser.url)
def test_search_paid_app(self): marketplace = Marketplace(self.marionette, "Marketplace Dev") marketplace.launch() results = marketplace.search("") self.assertGreater(len(results.search_results), 0, "No results found.") filter = results.tap_filter() filter.by_price("paid") results = filter.tap_apply() self.assertGreater(len(results.search_results), 0, "No results found.") for result in results.search_results: self.assertTrue(re.match("^\$\d+\.\d{2}", result.price), "App %s it's not a paid app." % result.name)
def test_marketplace_feedback_user(self): # launch marketplace dev and go to marketplace self.marketplace = Marketplace(self.marionette, self.MARKETPLACE_DEV_NAME) self.marketplace.launch() # wait for settings button to come out self.marketplace.wait_for_setting_displayed() settings = self.marketplace.tap_settings() # sign in with persona persona = settings.tap_sign_in() persona.login(self.user.email, self.user.password) # switch back to Marketplace self.marionette.switch_to_frame() self.marketplace.launch() # go to feedback tab self.marketplace.select_setting_feedback() # enter and submit your feedback self.marketplace.enter_feedback(self.test_comment) self.marketplace.submit_feedback() # catch the notification self.marketplace.wait_for_notification_message_displayed() message_content = self.marketplace.notification_message # verify if the notification is right self.assertEqual(message_content, self.feedback_submitted_message)
def setUp(self): MarketplaceGaiaTestCase.setUp(self) self.user = PersonaTestUser().create_user(verified=True, env={"browserid": "firefoxos.persona.org", "verifier": "marketplace-dev.allizom.org"}) self.marketplace = Marketplace(self.marionette, self.MARKETPLACE_DEV_NAME) self.marketplace.launch()
def test_marketplace_purchase_app_on_dev_with_mocked_bango(self): marketplace = Marketplace(self.marionette, 'Marketplace Dev') marketplace.launch() # Tap settings and sign in in Marketplace settings = marketplace.tap_settings() persona = settings.tap_sign_in() # login with PersonaTestUser account persona.login(self.user.email, self.user.password) # switch back to Marketplace self.marionette.switch_to_frame() marketplace.launch() # wait for the page to refresh and the sign out button to be visible settings.wait_for_sign_out_button() # Well I dunno, it just needs this time.sleep(3) settings.select_region("Spain") time.sleep(3) settings.tap_save_changes() marketplace.wait_for_notification_message_not_displayed() # search for a paid app and tap on the price search = marketplace.search(self._APP_NAME) bango = search.search_results[0].tap_purchase_button() # pay app bango.create_pin('1234') # make fake payment bango.make_fake_payment() self.marionette.switch_to_frame() # At gaia System level, complete the installation prompt self._confirm_installation() # Switch into homescreen frame homescreen_frame = self.marionette.find_element(*self._homescreen_iframe_locator) self.marionette.switch_to_frame(homescreen_frame) # Not overly concerned about it being visible, only present self.assertTrue(self.is_element_present(*self._app_icon_locator))
def test_login_during_purchase(self): pin = '1234' account = self.create_firefox_account() marketplace = Marketplace(self.marionette, self.MARKETPLACE_DEV_NAME) marketplace.launch() self.tap_install_button_of_first_paid_app() ff_accounts = FirefoxAccounts(self.marionette) ff_accounts.login(account.email, account.password) payment = Payment(self.marionette) payment.create_pin(pin) # Wait and check if confirm payment window appears payment.wait_for_buy_app_section_displayed() self.assertIn(self.app_name, payment.app_name)
def test_search_paid_app(self): APP_NAME = 'Test Zippy With Me' if self.apps.is_app_installed(APP_NAME): self.apps.uninstall(APP_NAME) marketplace = Marketplace(self.marionette, self.MARKETPLACE_DEV_NAME) marketplace.launch() marketplace.set_region('United States') search_results = marketplace.search(APP_NAME).search_results self.assertGreater(len(search_results), 0, 'No results found.') for result in search_results: if result.name == APP_NAME: saved_price = result.install_button_text details_page = result.tap_app() self.assertEqual(saved_price, details_page.install_button_text) return True # app not found self.fail('The app: %s was not found.' % APP_NAME)
def test_search_and_install_app(self): marketplace = Marketplace(self.marionette, self.MARKETPLACE_DEV_NAME) marketplace.launch() self.app_name = marketplace.popular_apps[0].name app_author = marketplace.popular_apps[0].author results = marketplace.search(self.app_name) self.assertGreater(len(results.search_results), 0, 'No results found.') first_result = results.search_results[0] self.assertEquals(first_result.name, self.app_name, 'First app has the wrong name.') self.assertEquals(first_result.author, app_author, 'First app has the wrong author.') # Find and click the install button to the install the web app self.assertEquals(first_result.install_button_text, 'Free', 'Incorrect button label.') first_result.tap_install_button() self.confirm_installation() marketplace.wait_for_notification_message_not_displayed() self.APP_INSTALLED = True # Check that the icon of the app is on the homescreen homescreen = Homescreen(self.marionette) homescreen.switch_to_homescreen_frame() self.assertTrue(homescreen.is_app_installed(self.app_name))
def install_in_app_payments_test_app(self, app_name): homescreen = Homescreen(self.marionette) # Remove the app if already installed if self.apps.is_app_installed(app_name): raise Exception('The app %s is already installed.' % app_name) marketplace = Marketplace(self.marionette, self.MARKETPLACE_DEV_NAME) home_page = marketplace.launch() details_page = home_page.navigate_to_app(app_name) details_page.tap_install_button() self.wait_for_downloads_to_finish() # Confirm the installation and wait for the app icon to be present confirm_install = ConfirmInstall(self.marionette) confirm_install.tap_confirm() self.device.touch_home_button() self.apps.switch_to_displayed_app() homescreen.wait_for_app_icon_present(app_name) return homescreen
def test_incorrect_pin(self): valid_pin = '1234' invalid_pin = '1111' account = self.create_firefox_account() marketplace = Marketplace(self.marionette, self.MARKETPLACE_DEV_NAME) home_page = marketplace.launch() home_page.login(account.email, account.password) search_results_page = self.tap_install_button_of_first_paid_app() payment = Payment(self.marionette) payment.create_pin(valid_pin) payment.wait_for_buy_app_section_displayed() self.assertIn(self.app_name, payment.app_name) payment.tap_cancel_button() search_results_page.wait_for_payment_cancelled_notification() search_results_page.search_results[0].tap_install_button() payment.switch_to_payment_frame() payment.enter_pin(invalid_pin) self.assertEqual('Wrong PIN', payment.pin_error)
class TestMarketplaceLogin(GaiaTestCase): MARKETPLACE_DEV_NAME = 'Marketplace Dev' def setUp(self): GaiaTestCase.setUp(self) self.connect_to_network() self.install_marketplace() self.user = PersonaTestUser().create_user(verified=True, env={"browserid": "firefoxos.persona.org", "verifier": "marketplace-dev.allizom.org"}) self.marketplace = Marketplace(self.marionette, self.MARKETPLACE_DEV_NAME) self.marketplace.launch() def test_login_marketplace(self): # https://moztrap.mozilla.org/manage/case/4134/ self.marketplace.wait_for_setting_displayed() settings = self.marketplace.tap_settings() persona = settings.tap_sign_in() persona.login(self.user.email, self.user.password) # switch back to Marketplace self.marionette.switch_to_frame() self.marketplace.launch() # wait for signed-in notification at the bottom of the screen to clear self.marketplace.wait_for_notification_message_not_displayed() # Verify that user is logged in self.assertEqual(self.user.email, settings.email) # Sign out, which should return to the Marketplace home screen settings.tap_sign_out() # Verify that user is signed out settings.wait_for_sign_in_displayed()
def test_purchase_app(self): APP_NAME = 'Test Zippy With Me' username = self.testvars['marketplace']['username'] password = self.testvars['marketplace']['password'] if self.apps.is_app_installed(APP_NAME): self.apps.uninstall(APP_NAME) marketplace = Marketplace(self.marionette, self.MARKETPLACE_DEV_NAME) marketplace.launch() marketplace.set_region('United States') details_page = marketplace.navigate_to_app(APP_NAME) ff_accounts = details_page.tap_purchase_button(is_logged_in=False) ff_accounts.login(username, password) # Switch back to the Marketplace frame and wait for the install button to update marketplace.switch_to_marketplace_frame() Wait(marionette=self.marionette, ignored_exceptions=StaleElementException)\ .until(lambda m: details_page.install_button_text == 'Purchasing')
def test_marketplace_feedback_anonymous(self): # launch marketplace dev and go to marketplace self.marketplace = Marketplace(self.marionette, self.MARKETPLACE_DEV_NAME) self.marketplace.launch() # go to settings page self.marketplace.tap_settings() self.marketplace.select_setting_feedback() # enter and submit your feedback self.marketplace.enter_feedback(self.test_comment) self.marketplace.submit_feedback() # catch the notification self.marketplace.wait_for_notification_message_displayed() message_content = self.marketplace.notification_message # verify if the notification is right self.assertEqual(message_content, self.feedback_submitted_message)
def test_create_confirm_pin(self): APP_NAME = 'Test Zippy With Me' PIN = '1234' username = self.testvars['marketplace']['username'] password = self.testvars['marketplace']['password'] if self.apps.is_app_installed(APP_NAME): self.apps.uninstall(APP_NAME) marketplace = Marketplace(self.marionette, self.MARKETPLACE_DEV_NAME) marketplace.launch() marketplace.login(username, password) marketplace.set_region('United States') details_page = marketplace.navigate_to_app(APP_NAME) payment = details_page.tap_purchase_button() payment.create_pin(PIN) payment.wait_for_buy_app_section_displayed() self.assertIn(APP_NAME, payment.app_name)
def test_add_review(self): APP_NAME = 'SoundCloud' username = self.testvars['marketplace']['username'] password = self.testvars['marketplace']['password'] marketplace = Marketplace(self.marionette, self.MARKETPLACE_DEV_NAME) marketplace.launch() marketplace.login(username, password) details_page = marketplace.navigate_to_app(APP_NAME) current_time = str(time.time()).split('.')[0] rating = random.randint(1, 5) body = 'This is a test %s' % current_time review_box = details_page.tap_write_review() review_box.write_a_review(rating, body) marketplace.wait_for_notification_message_displayed() # Check if review was added correctly self.assertEqual(marketplace.notification_message, "Your review was posted") self.assertEqual(details_page.first_review_rating, rating) self.assertEqual(details_page.first_review_body, body)
class TestMarketplaceFeedback(GaiaTestCase): MARKETPLACE_DEV_NAME = 'Marketplace Dev' feedback_submitted_message = u'Feedback submitted. Thanks!' test_comment = 'This is a test comment.' def setUp(self): GaiaTestCase.setUp(self) self.connect_to_network() self.install_marketplace() def test_marketplace_feedback_anonymous(self): # launch marketplace dev and go to marketplace self.marketplace = Marketplace(self.marionette, self.MARKETPLACE_DEV_NAME) self.marketplace.launch() # wait for settings button to come out self.marketplace.wait_for_setting_displayed() settings = self.marketplace.tap_settings() self.marketplace.select_setting_feedback() # enter and submit your feedback self.marketplace.enter_feedback(self.test_comment) self.marketplace.submit_feedback() # catch the notification self.marketplace.wait_for_notification_message_displayed() message_content = self.marketplace.notification_message # verify if the notification is right self.assertEqual(message_content, self.feedback_submitted_message)