def add_feature(self, url): """ Tries to add a feature (bookmark / place) to your Google Maps fav list. @return: - ADD_FEATURE_FAILURE if adding resulted in a known failure - ADD_FEATURE_SUCCESS if everything went fine - ADD_FEATURE_UNKNOWN_ERROR if we don't know what happened """ # This navigates Firefox to the passed URL self.client.navigate(url) # We wait for the fav button to be present... save_button = Wait(self.client, timeout=10).until( expected.element_present(By.CLASS_NAME, "section-entity-action-save-button")) # ... and to be displayed displayed = Wait(self.client, timeout=10).until( expected.element_displayed(save_button)) try: # Now we look for the correct text, it should say "SAVE" Wait(self.client, timeout=6).until(self.save_button_contains_correct_text_save) try: # Click it to add the feature (bookmark / place) to the Google Maps fav list save_button.click() except NoSuchElementException: pass try: # Now the text should be "SAVED" and this indicates it was saved Wait(self.client, timeout=6).until( self.save_button_contains_correct_text_saved) except TimeoutException: # We clicked but the fav button text didn't change, i.e. the click went wrong or timed out self.logger.error(" > [ERROR] Feature: '{}'".format(url)) save_button = self.client.find_element( By.CLASS_NAME, "section-entity-action-save-button") self.logger.error( " > [ERROR] Save button didn't switch to 'SAVED', it contains '{}'" .format(save_button.text)) return ADD_FEATURE_FAILURE return ADD_FEATURE_SUCCESS except TimeoutException: # This is the case if the fave button didn't contain the text "SAVE". # This can happen if it contains "SAVED", but this shouldn't happen in the # first place because we don't try to add features if we know that they're # already added. # So most likely something truly went wrong here. self.logger.error(" > [ERROR] Feature: '{}'".format(url)) save_button = self.client.find_element( By.CLASS_NAME, "section-entity-action-save-button") self.logger.error( " > [ERROR] Save button contained unknown text '{}'".format( save_button.text)) return ADD_FEATURE_UNKNOWN_ERROR
def add_feature_2(self, url, list_add): """ Tries to add a feature (bookmark / place) to your Google Maps fav list. @return: - """ self.client.navigate(url) try: saved_button = Wait(self.client, timeout=1).until( expected.element_present(By.CSS_SELECTOR, "[data-value='Saved']")) self.logger.info(" > Feature was already saved") return utils.constants.ADD_FEATURE_ALREADY_ADDED except TimeoutException: pass try: save_button = Wait(self.client, timeout=5).until( expected.element_present(By.CSS_SELECTOR, "[data-value='Save']")) Wait(self.client, timeout=5).until(expected.element_displayed(save_button)) except TimeoutException: self.logger.error(" > Unable to find save button") return utils.constants.ADD_FEATURE_UNKNOWN_ERROR save_button.click() if list_add == utils.constants.LIST_STARRED_PLACES: data_index = 2 elif list_add == utils.constants.LIST_WANT_TO_GO: data_index = 1 else: data_index = -1 css_selector = "#action-menu [data-index='{}']".format(data_index) sub_save_item = Wait(self.client, timeout=5).until( expected.element_present(By.CSS_SELECTOR, css_selector)) Wait(self.client, timeout=5).until(expected.element_displayed(sub_save_item)) sub_save_item.click()
def tap_order_by_last_name(self): last_name = Wait(self.marionette).until( expected.element_present(*self._order_by_last_name_locator)) Wait(self.marionette).until(expected.element_displayed(last_name)) last_name.click()
def test_fxa_sync(self): hostname = 'restmail.net' password = ''.join( [random.choice(string.ascii_letters) for i in range(8)]) account_email = 'fxa-e2e-' + ''.join( random.choice(string.ascii_lowercase) for _ in range(12)) email_pattern = account_email + '@' + hostname with self.marionette.using_context('content'): self.marionette.navigate(self.url_signup) Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present(By.ID, 'fxa-pp')) input_email = Wait( self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present(By.CSS_SELECTOR, '.input-row .email')) input_email.send_keys(email_pattern) input_password = Wait( self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present(By.ID, 'password')) input_password.send_keys(password) input_age = Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present(By.ID, 'age')) # repeat the send keys twice due to a bug with fast test runner typing input_age.send_keys('23') input_age.send_keys('23') self.marionette.find_element(By.ID, 'submit-btn').click() # Choose what to sync Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present( By.ID, 'fxa-choose-what-to-sync-header')) self.marionette.find_element(By.ID, 'submit-btn').click() # Confirm your account Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present(By.ID, 'fxa-confirm-header')) # Waiting for the email time.sleep(6) response = urllib.urlopen(self.url_restmail + account_email) email_data = json.loads(response.read()) self.marionette.navigate(email_data[0]['headers']['x-link']) # Due to A/B testing here we need to take a different path: Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present(By.ID, 'fox-logo')) # Account Confirmed time.sleep(4) if "connect_another_device" in self.marionette.get_url(): Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present( By.CSS_SELECTOR, '.graphic-connect-another-device')) else: Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present(By.CSS_SELECTOR, '.graphic-checkbox')) # give time for sync to kick in... time.sleep(3) self.marionette.navigate('about:preferences#sync') button_manage = Wait( self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present(By.ID, 'verifiedManage')) button_manage.click() # Wait for the window to open time.sleep(3) # Switch to the new Window self.marionette.switch_to_window(self.marionette.window_handles[1]) # Account settings Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present(By.ID, 'fxa-settings-profile-header')) # Login to reliers with this account # Add-ons self.marionette.navigate( 'https://addons.mozilla.org/en-US/firefox/') button_login = Wait( self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present(By.CSS_SELECTOR, '.login > a:nth-child(2)')) button_login.click() fxa_login = Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present( By.CSS_SELECTOR, '.use-logged-in')) fxa_login.click() Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present(By.CSS_SELECTOR, '.logout')) # Pocket self.marionette.navigate('https://getpocket.com/login') button_login = Wait( self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present(By.CSS_SELECTOR, '.login-btn-firefox')) button_login.click() fxa_login = Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present( By.CSS_SELECTOR, '.use-logged-in')) fxa_login.click() fxa_accept = Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present( By.CSS_SELECTOR, '#accept')) fxa_accept.click() Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present(By.CSS_SELECTOR, '.gsf_pocketlogo')) # Pontoon self.marionette.navigate('https://pontoon.mozilla.org/teams/') button_menu = Wait( self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present(By.CSS_SELECTOR, '.menu-icon')) button_menu.click() button_login = Wait( self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present(By.CSS_SELECTOR, '#fxa-sign-in')) button_login.click() fxa_login = Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present( By.CSS_SELECTOR, '.use-logged-in')) fxa_login.click() Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present(By.CSS_SELECTOR, '#sign-out')) # Test Basket Subscription self.marionette.navigate(self.url_settings) comm_prefs = Wait( self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present( By.CSS_SELECTOR, '#communication-preferences .settings-button')) comm_prefs.click() sub_button = Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present( By.CSS_SELECTOR, '#marketing-email-optin')) sub_button.click() time.sleep(6) self.marionette.refresh() time.sleep(2) comm_prefs = Wait( self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present( By.CSS_SELECTOR, '#communication-preferences .settings-button')) comm_prefs.click() Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present(By.CSS_SELECTOR, '#preferences-url')) # Unsubscribe sub_button = Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present( By.CSS_SELECTOR, '#marketing-email-optin')) sub_button.click() # Devices, check the device is in settings device_prefs = Wait( self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present(By.CSS_SELECTOR, '#clients .settings-button')) device_prefs.click() Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present(By.CSS_SELECTOR, '#clients .client-current')) # Display Name display_name_prefs = Wait( self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present(By.CSS_SELECTOR, '#display-name .settings-button')) display_name_prefs.click() display_input = Wait( self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present(By.CSS_SELECTOR, 'input.display-name')) display_input.send_keys('Display') Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present( By.CSS_SELECTOR, '#display-name .primary')).click() # Display Name - wait for close if successful Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present( By.CSS_SELECTOR, '#display-name.settings-unit:not(.open)')) # Delete account button_delete = Wait( self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present( By.CSS_SELECTOR, '#delete-account .settings-button')) button_delete.click() input_delete_password = Wait( self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present(By.CSS_SELECTOR, '#delete-account input.password')) input_delete_password.send_keys(password) button_delete = Wait( self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present( By.CSS_SELECTOR, '#delete-account button[type=submit]')) button_delete.click() # Deleted Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present(By.ID, 'fxa-signup-header')) self.marionette.close() print "FxA / Sync work!"