示例#1
0
 def test_valid_email_valid_pw_valid_cpw(self):
     create_valid_account()
     self.assertNotEqual(
         self.chk_url,
         get_current_url(),
         msg='FAILED: url = {0} - did not change after login'.format(
             get_current_url()))
     test_print('Successfully verified sign up', flash='!')
     stop()  # cleanup step
示例#2
0
 def verify_invalid_sign_in(self):
     self.verify_log_in_label()
     self.assertEqual(
         self.chk_url,
         get_current_url(),
         msg='FAILED: expected url = {0}, got url = {1}'.format(
             self.chk_url, get_current_url()))
     test_print(
         'Successfully verified login was unsuccessful, user is still on the sign_in page',
         flash='!')
 def test_invalid_email_forgot_password_send_password_button(self):
     set_forgot_your_password()
     url = get_current_url()
     set_email_field(invalid_email())
     actual = get_error_explanation(False)
     self.verify_sign_up_label()
     self.assertFalse(actual,
                      msg='FAILED: expected no error explanation, but got error explanation = "{0}" on url = {1}'.format(actual, get_current_url()))
     test_print('Successfully verified no error explanation'.format(actual), flash='!')
     self.assertEqual(url, get_current_url(),
                      msg='FAILED: expected url = {0}, got url = {1}'.format(url, get_current_url()))
     test_print('Successfully verified login was unsuccessful, user is still on the sign_up page', flash='!')
示例#4
0
文件: helpers.py 项目: miing/mci_migo
def logout_and_in():
    """Log out and then back in again, using the email and password from the
    last registered account. Returns to the initial url after login."""
    url = get_current_url()
    logout()
    login(_LAST_EMAIL, _LAST_PASSWORD)
    go_to(url)
 def test_login_link(self):
     set_log_in_link()
     expected_login_url = 'https://avant-qa-screening.herokuapp.com/users/sign_in'
     actual_url = get_current_url()
     self.assertEqual(expected_login_url, actual_url,
                  msg='FAILED: expected login url = {0}, got url = {1}'.format(expected_login_url, actual_url))
     test_print('Successfully verified the "Log in" link', flash='!')
     stop() # cleanup step
示例#6
0
def wait_click_url(ps=None, flash='#', attempts=10, index=0, element=None,
                   css_select=None, *args, **kwargs):
    """
    clicks url AND waits for url to change

    ps: logging message of your choosing
    type ps: string
    flash: accentuates your print statement in the console
    type flash: string
    index: will return the elment you specify by index
    type index: int
    attempts: number of tries, seperated by a 1 second sleep to get the elements
    type attempts: int
    xpath: an xpath like you would pass into get_element_by_xpath()
    type xpath: string
    css_select: a css selector like you would pass into get_element_by_css()
    type css_select: string
     *args, **kwargs: any element pair you would pass into get_element()
         e.g tag='some_tag_type', css_class='some_class_name'

    """
    chk_url = get_current_url()
    counter = 1
    while chk_url == get_current_url():
        if element:
            wait_for(click_element, element)
        elif css_select:
            try:
                wait_for(click_element, get_elements_by_css(css_select)[index])
            except Exception as e:
                if counter > 2:
                    test_print('ERROR: "{0}". Attempt {1} of {2}'.format(e, counter, attempts))
        else:
            try:
                wait_for(click_element, get_elements(*args, **kwargs)[index])
            except Exception as e:
                if counter > 2:
                    test_print('ERROR: "{0}". Attempt {1} of {2}'.format(e, counter, attempts))
        if counter == attempts:
            raise Exception('Error: The url did not change after {0} attempts'.format(attempts))
            break
        else:
            sleep(1)
        counter += 1
    if ps:
        test_print(ps, flash)
示例#7
0
 def verify_invalid_email(self):
     actual = get_error_explanation(False)
     self.verify_sign_up_label()
     self.assertFalse(
         actual,
         msg=
         'FAILED: expected no error explanation, but got error explanation = "{0}" on url = {1}'
         .format(actual, get_current_url()))
     test_print('Successfully verified no error explanation'.format(actual),
                flash='!')
     self.assertEqual(
         self.chk_url,
         get_current_url(),
         msg='FAILED: expected url = {0}, got url = {1}'.format(
             self.chk_url, get_current_url()))
     test_print(
         'Successfully verified login was unsuccessful, user is still on the sign_up page',
         flash='!')
 def test_valid_email_valid_pw(self):
     set_email_field(self.valid_email)
     set_password_field(self.valid_pw)
     set_log_in_button()
     expected = 'https://avant-qa-screening.herokuapp.com/dashboard'
     actual = get_current_url()
     self.assertEqual(expected, actual,
                      msg='FAILED: url expected after login = {0}, got url = {1}'.format(expected, actual))
     test_print('Successfully verified login', flash='!')
 def test_forgot_password_sign_up_link(self):
     set_forgot_your_password()
     set_sign_up_link()
     expected_signup_url ='https://avant-qa-screening.herokuapp.com/users/sign_up'
     actual_url = get_current_url()
     self.assertEqual(expected_signup_url, actual_url,
                  msg='FAILED: expected login url = {0}, got url = {1}'.format(expected_signup_url, actual_url))
     test_print('Successfully verified the "Sign up" link', flash='!')
     go_back()
示例#10
0
文件: devices.py 项目: miing/mci_migo
 def cleanup():
     go_to(urls.DEVICES)
     # cleanup assumes the user is logged in, otherwise we get a circular
     # dependency between helpers and devices
     msg = 'Can not cleanup devices if user is not logged in.'
     assert '+login' not in get_current_url(), msg
     while get_elements_by_css('#device-list td.name'):
         name = get_elements_by_css('#device-list td.name')[0].text
         print 'Deleting a device:', name
         delete_device()
示例#11
0
 def verify_sign_up_label(self):
     expected = 'Forgot your password?'
     actual = get_h2_label()
     self.assertEqual(
         expected,
         actual,
         msg='FAILED: expected h2 = "{0}", got h2 = "{1}" on url = {2}'.
         format(expected, actual, get_current_url()))
     test_print('Successfully verified h2 = "{0}"'.format(actual),
                flash='!')
示例#12
0
 def verify_landing_dash_page_links(self, h1_index, expected_link_url,
                                    back=True):
     # used in both landing and dashboard verification
     link = self.h1.split(' | ')[h1_index]
     wait_click_url(ps='clicking "{0}" link'.format(link), tag='a', text=link)
     actual = get_current_url()
     self.assertIn(expected_link_url, actual,
                      msg='FAILED: expected "{0}" link to open url = {1}, got url = {2}'.format(link, expected_link_url, actual))
     test_print('Successfully opened the "{0}" link'.format(link), flash='!')
     if back:
         go_back() # cleanup step
示例#13
0
 def test_login_link(self):
     set_log_in_link()
     expected_login_url = 'https://avant-qa-screening.herokuapp.com/users/sign_in'
     actual_url = get_current_url()
     self.assertEqual(
         expected_login_url,
         actual_url,
         msg='FAILED: expected login url = {0}, got url = {1}'.format(
             expected_login_url, actual_url))
     test_print('Successfully verified the "Log in" link', flash='!')
     stop()  # cleanup step
示例#14
0
 def test_valid_email_valid_pw(self):
     set_email_field(self.valid_email)
     set_password_field(self.valid_pw)
     set_log_in_button()
     expected = 'https://avant-qa-screening.herokuapp.com/dashboard'
     actual = get_current_url()
     self.assertEqual(
         expected,
         actual,
         msg='FAILED: url expected after login = {0}, got url = {1}'.format(
             expected, actual))
     test_print('Successfully verified login', flash='!')
示例#15
0
 def test_forgot_password_sign_up_link(self):
     set_forgot_your_password()
     set_sign_up_link()
     expected_signup_url = 'https://avant-qa-screening.herokuapp.com/users/sign_up'
     actual_url = get_current_url()
     self.assertEqual(
         expected_signup_url,
         actual_url,
         msg='FAILED: expected login url = {0}, got url = {1}'.format(
             expected_signup_url, actual_url))
     test_print('Successfully verified the "Sign up" link', flash='!')
     go_back()
示例#16
0
文件: devices.py 项目: miing/mci_migo
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
示例#17
0
 def report_extensively(self, exc_info):
     exc_class, exc, tb = exc_info
     original_message = str(exc)
     try:
         current_url = actions.get_current_url()
     except Exception:
         current_url = 'unavailable'
     try:
         page_source = actions.get_page_source()
     except Exception:
         page_source = 'unavailable'
     self.addDetail(
         'Original exception',
         testtools.content.text_content('{0} : {1}'.format(
             exc.__class__.__name__, original_message)))
     self.addDetail('Current url',
                    testtools.content.text_content(current_url))
     self.addDetail('Page source',
                    testtools.content.text_content(page_source))
 def report_extensively(self, exc_info):
     exc_class, exc, tb = exc_info
     original_message = str(exc)
     try:
         current_url = actions.get_current_url()
     except Exception:
         current_url = 'unavailable'
     try:
         page_source = actions.get_page_source()
     except Exception:
         page_source = 'unavailable'
     self.addDetail(
         'Original exception',
         testtools.content.text_content('{0} : {1}'.format(
             exc.__class__.__name__, original_message)))
     self.addDetail('Current url',
                    testtools.content.text_content(current_url))
     self.addDetail('Page source',
                    testtools.content.text_content(page_source))
 def test_valid_email_valid_pw_valid_cpw(self):
     create_valid_account()
     self.assertNotEqual(self.chk_url, get_current_url(),
                      msg='FAILED: url = {0} - did not change after login'.format(get_current_url()))
     test_print('Successfully verified sign up', flash='!')
     stop() # cleanup step
示例#20
0
 def verify_error_explanation(self, expected):
     actual = get_error_explanation()
     self.verify_sign_up_label()
     self.assertEqual(expected, actual,
                      msg='FAILED: expected error explanation = "{0}", got expected error explanation = "{1}" on url = {2}'.format(expected, actual, get_current_url()))
     test_print('Successfully verified expected error explanation = "{0}"'.format(actual), flash='!')
 def verify_sign_up_label(self):
     expected = 'Forgot your password?'
     actual = get_h2_label()
     self.assertEqual(expected, actual,
                      msg='FAILED: expected h2 = "{0}", got h2 = "{1}" on url = {2}'.format(expected, actual, get_current_url()))
     test_print('Successfully verified h2 = "{0}"'.format(actual), flash='!')
 def verify_invalid_sign_in(self):
     self.verify_log_in_label()
     self.assertEqual(self.chk_url, get_current_url(),
                      msg='FAILED: expected url = {0}, got url = {1}'.format(self.chk_url, get_current_url()))
     test_print('Successfully verified login was unsuccessful, user is still on the sign_in page', flash='!')
示例#23
0
    def test(self):
        if context_provided:
            if actions.VERBOSE:
                print '    Loading data row %r' % context['_row_num']
        try:
            exec self.code in context
        except EndTest:
            pass
        except SkipTest:
            raise
        except:
            exc_class, exc, tb = sys.exc_info()
            if screenshots_on:
                now = datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S')
                tc_name = entry[:-3]
                try:
                    filename = 'screenshot-%s-%s.png' % (now, tc_name)
                    take_screenshot(filename)
                except Exception:
                    # FIXME: Needs to be reported somehow ? -- vila 2012-10-16
                    pass
                try:
                    # also dump page source
                    filename = 'pagesource-%s-%s.html' % (now, tc_name)
                    path = os.path.join(config.results_directory, filename)
                    with codecs.open(path, 'w', encoding='utf-8') as f:
                        f.write(get_page_source())
                except Exception:
                    # FIXME: Needs to be reported somehow ? -- vila 2012-10-16
                    pass
            if debug:
                traceback.print_exc()
                pdb.post_mortem()
            if not extended:
                raise exc_class, exc, tb
            original_message = str(exc)
            page_source = 'unavailable'
            current_url = 'unavailable'
            try:
                current_url = actions.get_current_url()
            except Exception:
                pass
            try:
                page_source = get_page_source()
            except Exception:
                pass

            new_message = dedent("""
            Original exception: %s: %s

            Current url: %s

            Page source:

            %s

            """[1:]) % (
                   exc.__class__.__name__,
                   original_message,
                   current_url,
                   page_source,
            )
            if isinstance(new_message, unicode):
                new_message = new_message.encode('ascii', 'backslashreplace')
            new_exc = Exception(new_message)
            raise Exception, new_exc, tb