def _account_menu_1_9(self, item): account = a.get_element_by_xpath( "//a[contains(@class, 'skip-account')]") a.click_link(account) link = a.get_element_by_xpath("//a[@title='%s']" % item) a.click_link(link)
def customer_edit_by_email(self, email): edit_link = a.get_element_by_xpath( "//table[@id='customerGrid_table']" "//td[%s]" "//.." "//a" % (xpath_contains_text(email)) ) a.click_link(edit_link)
def add_billing_address(self): # from the account page manage_link = a.get_element_by_xpath("//a[text()='Manage Addresses']") a.click_link(manage_link) fill_user_form(self._data, version=self._version) button = a.get_element_by_xpath("//button[@title='Save Address']") a.click_button(button)
def rename_device(name, new_name): click_link(get_element(tag='a', text_regex='Rename')) # find name textfield elem = get_element(tag='input', name='name', value=name) # and update it write_textfield(elem, new_name) # and submit the form click_button(get_element(tag='button', text='Rename'))
def rebuild_indexes(self): self.navigate('System', 'Index Management') select_all_link = a.get_element_by_xpath( "//a[%s]" % ( xpath_contains_text('Select All')) ) a.click_link(select_all_link) a.set_dropdown_value('indexer_processes_grid_massaction-select', 'Reindex Data') self.click_magento_button('Submit')
def _get_paper_device_codes(counter): url = get_current_url() restore = False if not re.match(r'.*/device-print/\d+$', url): assert_url('/device-list') click_link(get_element(tag='a', text='View Codes')) restore = True codes = [e.text for e in get_elements_by_css('ol.codelist li')][counter:] if restore: go_to('/device-list') return codes
def navigate(self, first, second): # no idea how to hover, but there's a false click handler so that works hover_link = a.get_element_by_xpath( "//li[%s]/*/*[%s]/.." % ( xpath_contains_class('level0'), xpath_contains_text(first)) ) a.click_link(hover_link) final_link = a.get_element_by_xpath( "//li[%s]/*/*[%s]/.." % ( xpath_contains_class('level1'), xpath_contains_text(second)) ) a.click_link(final_link)
def login(self): go_to('admin/') a.assert_title_contains('Admin') fill_user_form(self._data) button = a.get_element_by_xpath("//input[@title='Login']") a.click_button(button) # do away with messages if any close = None try: close = a.get_element_by_xpath( "//div[@id='message-popup-window']" "//a[@title='close']") except AssertionError: pass if close: a.click_link(close)
def register(self): if self._version >= (1, 9, 0, 0): self._account_menu_1_9('Register') else: a.click_link(a.get_element(text='My Account')) button = a.get_element_by_xpath( "//button[@title='Create an Account']") a.click_button(button) # fill in data for mary and register fill_user_form(self._data, version=self._version) if self._version >= (1, 9, 0, 0): title = 'Register' else: title = 'Submit' button = a.get_element_by_xpath("//button[@title='%s']" % title) a.click_button(button)
def login(self): if self._version >= (1, 9, 0, 0): self._account_menu_1_9('Log In') else: a.click_link(a.get_element(text='Log In')) # fill in data on login screen data = { 'email': self._data['email_address'], 'pass': self._data['password'], } fill_user_form(data, version=self._version) button = a.get_element_by_xpath("//button[@title='Login']") a.click_button(button) e = a.get_element_by_xpath("//p[@class='welcome-msg']") assert e.text.upper() == u'WELCOME, MARY BERNARD!', \ "Login failed: %r" % e.text
config.set_base_url_from_env() # Create account or login, then add a device helpers.login_or_register_account(device_cleanup=True) aes_key = add_device('logout_deep_pages') # Logout and back in so we are no longer 2f-authenticated helpers.logout_and_in() # Create a device to get a deep page and then start to delete it go_to(urls.DEVICES) click_delete_button() authenticate() assert_url_contains('/device-removal/\d+', regex=True) # logout by clicking on link click_link('logout-link') # no link present in ubuntuone brand if get_current_brand() != 'ubuntuone': assert_element(href="/+login") # make sure we're logged out go_to(urls.HOME) assert_title('Log in') # login again so that cleanup method can do its work helpers.logout_and_in()
def logout(self): a.click_link(a.get_element(text='Log Out'))
email_address = mail.make_unique_test_email_address() account_password = '******' go_to(urls.NEW_ACCOUNT) assert_title('Create account') helpers.register_account(email_address, password=account_password) wait_for(assert_element, **{'data-qa-id': 'edit_account'}) # Depending whether we're on Production or Staging different tests if get_base_url() == 'https://login.ubuntu.com': # Production # shop go_to('http://shop.canonical.com') wait_for(assert_title, 'Canonical Store') click_link(get_element(href="https://shop.canonical.com/login.php")) wait_for(get_element, id='id_email') write_textfield('id_email', email_address) write_textfield('id_password', account_password) click_button(get_element(name='continue')) click_button(get_element(name='yes')) wait_for(get_element, name='email_address') assert_element(value=email_address) # launchpad go_to('https://launchpad.net/~canonical-isd-hackers/+archive/internal-qa/' '+index') click_button(get_element(name='yes')) assert_element(tag='h1', text='Not allowed here') # wiki
def logout(self): if self._version >= (1, 9, 0, 0): self._account_menu_1_9('Log Out') else: a.click_link(a.get_element(text='Log Out'))
) from u1testutils.sst import config from acceptance.helpers import logout, production_only config.set_base_url_from_env() # Some external sites have extraordinary wait times set_wait_timeout(20) # Check whether we're on Production or not production_only() # Ubuntu One go_to('http://ubuntuone.com') click_link(get_element(text="Log in or Sign up")) write_textfield('id_email', settings.SSO_TEST_ACCOUNT_EMAIL) write_textfield('id_password', settings.SSO_TEST_ACCOUNT_PASSWORD) click_button(get_element(name='continue')) assert_element(tag='span', text='Welcome ISD Test') logout() # Payment system go_to('https://pay.ubuntu.com/') click_link(get_element(text="Log in or Register")) wait_for(assert_title, 'Log in') write_textfield('id_email', settings.SSO_TEST_ACCOUNT_EMAIL) write_textfield('id_password', settings.SSO_TEST_ACCOUNT_PASSWORD) click_button(get_element(name='continue')) assert_element(tag='h1', text='Your payment history') logout()
wait_for, ) from u1testutils.sst import config from acceptance import helpers, urls # Interacting with external sites can take a long time set_wait_timeout(20) config.set_base_url_from_env() helpers.skip_unless_staging_or_production() helpers.login_to_test_account() go_to("https://bitbucket.org/account/signin/") click_link(get_element(text="OpenID log in")) def openid_link_is_visible(): return get_element(href="#openid", title="OpenID").is_displayed() wait_for(openid_link_is_visible) click_link(get_element(href="#openid", title="OpenID")) wait_for(lambda: get_element(tag='input', id='openid-url').is_displayed()) input = get_element(tag='input', id='openid-url') input.clear() input.send_keys(get_base_url()) submit_button = get_element_by_css( 'div.buttons.selected button[type=submit]') click_button(submit_button)
def click_add_new_device_link(): click_link( get_element(tag='a', text_regex='^Add a new authentication device'))
config.set_base_url_from_env() edit_account_anchor = {'data-qa-id': 'edit_account'} # Create an account and logout. email_address = helpers.register_account( displayname="Fred Jones", verify=True ) helpers.logout() # Request the password reset. go_to(urls.HOME) assert_title('Log in') click_link('forgotpw-link') write_textfield('id_email', email_address) # Even though the recaptcha field is ignored for our tests, we do # want to verify that it is on the page. write_textfield('recaptcha_response_field', 'ignored') click_button(get_element(name='continue')) assert_element(**{'data-qa-id': 'forgot_password_step_2'}) # Fetch and verify the confirmation code. vcode = mail.get_verification_code_for_address(email_address) write_textfield(get_element(name='confirmation_code'), vcode) click_button(get_element(css_class='btn')) # Reset the password and verify that we're logged in. assert_title('Reset password')
def click_delete_button(): """Remove the first device in the list by clicking the delete button.""" # Clicks the first Delete button it finds # this button is actually a link click_link(get_elements(tag='a', text_regex='Delete')[0])
# confirm device renamed assert_device('rename_device_new') assert_no_device(name) # sad paths # rename escapes content name = '<script>alert("rename_device");</script>' rename_device('rename_device_new', name) assert_device(name) assert_no_device('rename_device_new') # try to rename to empty string rename_device(name, '') # rename should have failed assert_url_contains('/device-rename/\d+', regex=True) # check error message assert_text('name-error', 'This field is required.') # cancel and go back click_link(get_element(tag='a', text_regex='[cC]ancel')) # spaces get trimmed rename_device(name, ' ') # rename should have failed assert_url_contains('/device-rename/\d+', regex=True) # check error message wait_for(assert_text, 'name-error', 'The name must contain at least one non-whitespace character.') # cancel and go back click_link(get_element(tag='a', text_regex='[cC]ancel'))
from acceptance.devices import ( add_device, authenticate, enter_otp, ) from acceptance import helpers config.set_base_url_from_env() base_url = get_base_url() email = helpers.login_or_register_account(device_cleanup=True) # Go to the authentication devices page click_link('devices-link') # Add an authentication device add_device('login') # Change the preference to always require 2 factor authentication and save helpers.set_twofactor_to_always_required() # Logout and attempt to log back in helpers.logout_and_in() # Should insist on 2F and not give access to '/' # In response to defect #923814 go_to(base_url) # Check we are on the 2-factor login page