コード例 #1
0
    def test_1_detail_form_elements(self):
        print(
            colored('Running: test_1_detail_form_elements - estimate: 24s',
                    'yellow'))

        for i in range(3):
            print(colored('\trandom meter ' + str(i + 1), 'magenta'))

            meter_row = get_random_table_row()
            meter_cols = meter_row.find_elements_by_tag_name('td')
            click_action_button(meter_cols)

            meter_detail_form_ids = [
                'meter-name', 'serial-number', 'endpoint-address',
                'device-model', 'pulse-weight', 'volume-unit',
                'pairing-status', 'installed-on', 'activated-on', 'is-active',
                'deactivated-on', 'deleted-on'
            ]

            for input_id in meter_detail_form_ids:
                print(
                    colored(
                        '\ttest_1_detail_form_elements: input "' + input_id +
                        '" existence - asserting...', 'blue'))
                self.assertTrue(check_existence(input_id))

            close_modal()

        print(colored('\ttest_1_detail_form_elements: passed.', 'cyan'))
コード例 #2
0
    def test_1_detail_form_elements(self):
        print(
            colored('Running: test_1_detail_form_elements - estimate: 24s',
                    'yellow'))

        for i in range(3):
            print(colored('\trandom node ' + str(i + 1), 'magenta'))

            node_row = get_random_table_row()
            node_cols = node_row.find_elements_by_tag_name('td')
            click_action_button(node_cols)

            node_detail_form_ids = [
                'device-name', 'hex-address', 'dec-address', 'serial-number',
                'device-model', 'installed-on', 'serviced-on', 'deleted-on'
            ]

            for input_id in node_detail_form_ids:
                print(
                    colored(
                        '\ttest_2_node_details: input "' + input_id +
                        '" existence - asserting...', 'blue'))
                self.assertTrue(check_existence(input_id))

            close_modal()

        print(colored('\ttest_1_detail_form_elements: passed.', 'cyan'))
コード例 #3
0
    def test_2_detail_form_elements(self):
        print(
            colored('Running: test_2_detail_form_elements - estimate: 24s',
                    'yellow'))

        for i in range(3):
            print(colored('\trandom gateway ' + str(i + 1), 'magenta'))

            gateway_row = get_random_table_row()
            gateway_cols = gateway_row.find_elements_by_tag_name('td')
            click_action_button(gateway_cols)

            gateway_detail_form_ids = [
                'gateway-imei', 'gateway-name', 'phone-number',
                'serial-number', 'hex-address', 'dec-address', 'ip-address',
                'software-version', 'firmware-version', 'sim-serial',
                'sim-puk', 'device-model', 'installed-on', 'created-on',
                'updated-on'
            ]

            for input_id in gateway_detail_form_ids:
                print(
                    colored(
                        '\ttest_2_detail_form_elements: input "' + input_id +
                        '" existence - asserting...', 'blue'))
                self.assertTrue(check_existence(input_id))

            close_modal()

        print(colored('\ttest_2_detail_form_elements: passed.', 'cyan'))
コード例 #4
0
    def test_2_correct_details(self):
        print(colored('Running: test_2_correct_details - estimate: 24s', 'yellow'))

        for i in range(3):
            print(colored('\trandom command ' + str(i + 1), 'magenta'))

            command_row = get_random_table_row()
            command_cols = command_row.find_elements_by_tag_name('td')

            command_table_headers = get_table_headers()
            command_name_in_table = command_cols[command_table_headers.index('Name')].get_attribute('innerHTML')
            command_syntax_in_table = command_cols[command_table_headers.index('Command')].get_attribute('innerHTML')
            command_type_in_table = command_cols[command_table_headers.index('Type')].get_attribute('innerHTML')

            click_action_button(command_cols)

            command_detail_form = browser.find_element_by_xpath('//div[@class="MuiFormControl-root"]')
            command_name_in_form = command_detail_form.find_element_by_id('command-name').get_attribute('value')
            command_syntax_in_form = command_detail_form.find_element_by_id('command-syntax').get_attribute('value')
            command_type_in_form = command_type_in_table # command_detail_form.find_element_by_id('command-type').get_attribute('value')

            print(colored('\ttest_2_command_details: is correct command - asserting...', 'blue'))
            self.assertEqual(command_name_in_table, command_name_in_form)
            self.assertEqual(command_syntax_in_table, command_syntax_in_form)
            self.assertEqual(command_type_in_table, command_type_in_form)

            close_modal()

        print(colored('\ttest_2_correct_details: passed.', 'cyan'))
コード例 #5
0
    def test_2_confirm_no_network():
        print(
            colored('Running: test_2_confirm_no_network - estimate: 40s',
                    'yellow'))
        prompt_to_disable_network()

        inactive_user_row = get_random_row_in_account_table(active=False)
        inactive_user_cols = inactive_user_row.find_elements_by_tag_name('td')
        click_action_button(inactive_user_cols)
        sleep(SLEEP_INTERVAL)

        browser.switch_to_alert().accept()
        sleep(9 + SLEEP_INTERVAL)

        print(
            colored(
                '\ttest_2_confirm_no_network: revival failed - asserting...',
                'blue'))
        confirmation = browser.switch_to_alert()
        assert 'Error occurred while reviving account' in confirmation.text

        confirmation.accept()

        print(colored('\ttest_2_confirm_no_network: passed.', 'cyan'))
        prompt_to_enable_network_and_setup(browser,
                                           'Administration/ManageUser')
コード例 #6
0
    def test_2_confirm_no_network():
        print(
            colored('Running: test_2_confirm_no_network - estimate: 40s',
                    'yellow'))
        prompt_to_disable_network()

        for i in range(3):
            print(colored('\trandom account ' + str(i + 1), 'magenta'))
            active_user_row = get_random_row_in_account_table()
            active_user_cols = active_user_row.find_elements_by_tag_name('td')
            click_action_button(active_user_cols)

            browser.find_element_by_id('delete-button').send_keys(Keys.ENTER)
            sleep(SLEEP_INTERVAL)

            browser.switch_to_alert().accept()
            sleep(9 + SLEEP_INTERVAL)

            print(
                colored(
                    '\ttest_2_confirm_no_network: deletion failed - asserting...',
                    'blue'))
            confirmation = browser.switch_to_alert()
            assert 'Error occurred while deleting account' in confirmation.text

            confirmation.accept()
            browser.find_element_by_id('cancel-button').send_keys(Keys.ENTER)
            sleep(SLEEP_INTERVAL)

        print(colored('\ttest_2_confirm_no_network: passed.', 'cyan'))
        prompt_to_enable_network_and_setup(browser,
                                           'Administration/ManageUser')
コード例 #7
0
def get_back_previously_updated_meter(serial):
    meter_table_headers = get_table_headers()
    rows = browser.find_elements_by_xpath(
        '//tbody[@class="MuiTableBody-root"]/tr')
    for row in rows:
        cols = row.find_elements_by_tag_name('td')
        if serial == cols[meter_table_headers.index(
                'Serial No.')].get_attribute('innerHTML'):
            click_action_button(cols)
            break
コード例 #8
0
def get_random_meter():
    meter_row = get_random_table_row()
    meter_cols = meter_row.find_elements_by_tag_name('td')

    meter_table_headers = get_table_headers()
    meter_serial = meter_cols[meter_table_headers.index(
        'Serial No.')].get_attribute('innerHTML')
    click_action_button(meter_cols)

    return meter_serial
コード例 #9
0
def get_back_previously_updated_gateway(imei):
    gateway_table_headers = get_table_headers()
    rows = browser.find_elements_by_xpath(
        '//tbody[@class="MuiTableBody-root"]/tr')
    for row in rows:
        cols = row.find_elements_by_tag_name('td')
        if imei == cols[gateway_table_headers.index('Imei')].get_attribute(
                'innerHTML'):
            click_action_button(cols)
            break
コード例 #10
0
def get_random_gateway():
    gateway_row = get_random_table_row()
    gateway_cols = gateway_row.find_elements_by_tag_name('td')

    gateway_table_headers = get_table_headers()
    gateway_imei = gateway_cols[gateway_table_headers.index(
        'Imei')].get_attribute('innerHTML')
    click_action_button(gateway_cols)

    return gateway_imei
コード例 #11
0
def get_back_previously_updated_command(cmd):
    command_table_headers = get_table_headers()
    rows = browser.find_elements_by_xpath(
        '//tbody[@class="MuiTableBody-root"]/tr')
    for row in rows:
        cols = row.find_elements_by_tag_name('td')
        if len(cols) > 0 and cmd == cols[command_table_headers.index(
                'Command')].get_attribute('innerHTML'):
            click_action_button(cols)
            break
コード例 #12
0
def get_random_node():
    node_row = get_random_table_row()
    node_cols = node_row.find_elements_by_tag_name('td')

    node_table_headers = get_table_headers()
    node_hex = node_cols[node_table_headers.index(
        'Hex. Address')].get_attribute('innerHTML')
    click_action_button(node_cols)

    return node_hex
コード例 #13
0
def get_back_previously_updated_node(hex):
    node_table_headers = get_table_headers()
    rows = browser.find_elements_by_xpath(
        '//tbody[@class="MuiTableBody-root"]/tr')
    for row in rows:
        cols = row.find_elements_by_tag_name('td')
        if hex == cols[node_table_headers.index('Hex. Address')].get_attribute(
                'innerHTML'):
            click_action_button(cols)
            break
コード例 #14
0
    def test_3_correct_details(self):
        print(
            colored('Running: test_3_correct_details - estimate: 24s',
                    'yellow'))

        for i in range(3):
            print(colored('\trandom gateway ' + str(i + 1), 'magenta'))

            gateway_row = get_random_table_row()
            gateway_cols = gateway_row.find_elements_by_tag_name('td')

            gateway_table_headers = get_table_headers()
            gateway_imei_in_table = gateway_cols[gateway_table_headers.index(
                'Imei')].get_attribute('innerHTML')
            gateway_serial_in_table = gateway_cols[gateway_table_headers.index(
                'Serial No.')].get_attribute('innerHTML')
            gateway_hex_in_table = gateway_cols[gateway_table_headers.index(
                'Hex. Address')].get_attribute('innerHTML')
            gateway_dec_in_table = gateway_cols[gateway_table_headers.index(
                'Dec. Address')].get_attribute('innerHTML')
            gateway_ip_in_table = gateway_cols[gateway_table_headers.index(
                'IP Address')].get_attribute('innerHTML')
            gateway_phone_in_table = gateway_cols[gateway_table_headers.index(
                'Phone No.')].get_attribute('innerHTML')
            click_action_button(gateway_cols)

            gateway_detail_form = browser.find_element_by_xpath(
                '//div[@class="MuiFormControl-root"]')
            gateway_imei_in_form = gateway_detail_form.find_element_by_id(
                'gateway-imei').get_attribute('value')
            gateway_serial_in_form = gateway_detail_form.find_element_by_id(
                'serial-number').get_attribute('value')
            gateway_hex_in_form = gateway_detail_form.find_element_by_id(
                'hex-address').get_attribute('value')
            gateway_dec_in_form = gateway_detail_form.find_element_by_id(
                'dec-address').get_attribute('value')
            gateway_ip_in_form = gateway_detail_form.find_element_by_id(
                'ip-address').get_attribute('value')
            gateway_phone_in_form = gateway_detail_form.find_element_by_id(
                'phone-number').get_attribute('value')

            print(
                colored(
                    '\ttest_3_correct_details: is correct gateway - asserting...',
                    'blue'))
            self.assertEqual(gateway_imei_in_table, gateway_imei_in_form)
            self.assertEqual(gateway_serial_in_table, gateway_serial_in_form)
            self.assertEqual(gateway_hex_in_table, gateway_hex_in_form)
            self.assertEqual(gateway_dec_in_table, gateway_dec_in_form)
            self.assertEqual(gateway_ip_in_table, gateway_ip_in_form)
            self.assertEqual(gateway_phone_in_table, gateway_phone_in_form)

            close_modal()

        print(colored('\ttest_3_correct_details: passed.', 'cyan'))
コード例 #15
0
    def test_5_no_network(self):
        print(colored('Running: test_5_no_network - estimate: 11s', 'yellow'))
        prompt_to_disable_network()

        active_user_row = get_random_row_in_account_table()
        click_action_button(active_user_row.find_elements_by_tag_name('td'))
        sleep(9+SLEEP_INTERVAL)

        print(colored('\ttest_5_no_network: no account form - asserting...', 'blue'))
        self.assertFalse(check_existence('//div[@class="MuiFormControl-root MuiFormControl-fullWidth"]', is_id=False))
        self.assertTrue(check_existence('//div[@class="inform"]', is_id=False))

        print(colored('\ttest_5_no_network: passed.', 'cyan'))
コード例 #16
0
def get_random_command():
    while True:
        command_row = get_random_table_row()
        command_cols = command_row.find_elements_by_tag_name('td')

        if len(command_cols) > 0:
            break

    command_table_headers = get_table_headers()
    command = command_cols[command_table_headers.index(
        'Command')].get_attribute('innerHTML')
    click_action_button(command_cols)

    return command
コード例 #17
0
    def test_3_detail_closed(self):
        print(colored('Running: test_3_detail_closed - estimate: 19s', 'yellow'))

        for i in range(3):
            print(colored('\trandom command ' + str(i + 1), 'magenta'))

            command_row = get_random_table_row()
            command_cols = command_row.find_elements_by_tag_name('td')
            click_action_button(command_cols)
            close_modal()

            print(colored('\ttest_3_detail_closed: modal closed - asserting...', 'blue'))
            self.assertFalse(check_existence('//div[@class="MuiFormControl-root"]', is_id=False))
            sleep(2*SLEEP_INTERVAL)

        print(colored('\ttest_3_detail_closed: passed.', 'cyan'))
コード例 #18
0
    def test_3_device_model_dropdown(self):
        print(
            colored('Running: test_3_device_model_dropdown - estimate: 39s',
                    'yellow'))

        for i in range(3):
            print(colored('\trandom meter ' + str(i + 1), 'magenta'))

            meter_row = get_random_table_row()
            meter_cols = meter_row.find_elements_by_tag_name('td')
            click_action_button(meter_cols)

            meter_detail_form = browser.find_element_by_xpath(
                '//div[@class="MuiFormControl-root"]')
            device_model_dropdown = meter_detail_form.find_element_by_id(
                'device-model')
            device_model_dropdown.send_keys(Keys.ENTER)
            sleep(SLEEP_INTERVAL)

            device_model_items = browser.find_elements_by_xpath(
                '//ul[@class="MuiList-root MuiMenu-list '
                'MuiList-padding"]/div')
            print(
                colored(
                    '\ttest_3_device_model_dropdown: device models count - asserting...',
                    'blue'))
            self.assertGreaterEqual(len(device_model_items), 1)

            random_device_model = get_random_dropdown_item(device_model_items)
            random_model_value = random_device_model.find_element_by_xpath(
                '//span/div/div').get_attribute('innerHTML')
            random_device_model.click()

            sleep(SLEEP_INTERVAL)
            random_model_selected = random_model_value  # browser.find_element_by_id('device-model').get_attribute('innerHTML')
            print(
                colored(
                    '\ttest_3_device_model_dropdown: device models selected - asserting...',
                    'blue'))
            self.assertEqual(random_model_value, random_model_selected)

            close_modal()

        print(colored('\ttest_3_device_model_dropdown: passed.', 'cyan'))
コード例 #19
0
    def test_1_detail_form_elements(self):
        print(colored('Running: test_1_detail_form_elements - estimate: 2s', 'yellow'))
        account_details_form_ids = ['full-name', 'email-address', 'organization', 'jira-token',
                                    'username', 'account-password', 'confirm-password']

        for el_id in account_details_form_ids:
            print(colored('\ttest_1_detail_form_elements: input "' + el_id + '" existence - asserting...', 'blue'))
            self.assertTrue(check_existence(el_id))

        print(colored('\ttest_1_detail_form_elements: input new-password existence - asserting...', 'blue'))
        self.assertFalse(check_existence('new-password'))

        active_user = get_random_row_in_account_table()
        click_action_button(active_user.find_elements_by_tag_name('td'))
        sleep(SLEEP_INTERVAL)

        print(colored('\ttest_1_detail_form_elements: input new-password existence - asserting...', 'blue'))
        self.assertTrue(check_existence('new-password'))

        print(colored('\ttest_1_detail_form_elements: passed.', 'cyan'))
コード例 #20
0
    def test_1_detail_no_network(self):
        print(
            colored('Running: test_1_detail_no_network - estimate: 24s',
                    'yellow'))
        prompt_to_disable_network()

        gateway_row = get_random_table_row()
        gateway_cols = gateway_row.find_elements_by_tag_name('td')
        click_action_button(gateway_cols)
        sleep(3 * SLEEP_INTERVAL)

        print(
            colored(
                '\ttest_1_detail_no_network: inform existence - asserting...',
                'blue'))
        self.assertTrue(check_existence('//div[@class="inform"]', is_id=False))

        print(colored('\ttest_1_detail_no_network: passed.', 'cyan'))
        browser.refresh()
        prompt_to_enable_network_and_setup(browser, 'Factory/ManageGateways')
コード例 #21
0
    def test_1_detail_form_elements(self):
        print(colored('Running: test_1_detail_form_elements - estimate: 24s', 'yellow'))

        for i in range(3):
            print(colored('\trandom command ' + str(i + 1), 'magenta'))

            command_row = get_random_table_row()
            command_cols = command_row.find_elements_by_tag_name('td')
            click_action_button(command_cols)

            cmd_detail_form_ids = ['command-name', 'device-model', 'command-type', 'command-syntax',
                                   'command-description', 'created-on', 'created-by', 'updated-on', 'updated-by']

            for input_id in cmd_detail_form_ids:
                print(colored('\ttest_2_command_details: input "' + input_id + '" existence - asserting...', 'blue'))
                self.assertTrue(check_existence(input_id))

            close_modal()

        print(colored('\ttest_1_detail_form_elements: passed.', 'cyan'))
コード例 #22
0
    def test_4_correct_details(self):
        print(colored('Running: test_4_correct_details - estimate: 5s', 'yellow'))
        account_table_headers = get_table_headers()

        active_user_row = get_random_row_in_account_table()
        active_user_cols = active_user_row.find_elements_by_tag_name('td')
        click_action_button(active_user_cols)

        fullname_in_table = active_user_cols[account_table_headers.index('Full Name')].get_attribute('innerHTML')
        username_in_table = active_user_cols[account_table_headers.index('Username')].get_attribute('innerHTML')
        email_in_table = active_user_cols[account_table_headers.index('Email')].get_attribute('innerHTML')

        fullname_in_form = browser.find_element_by_id('full-name').get_attribute('value')
        username_in_form = browser.find_element_by_id('username').get_attribute('value')
        email_in_form = browser.find_element_by_id('email-address').get_attribute('value')

        print(colored('\ttest_4_correct_details: user details - asserting...', 'blue'))
        self.assertEqual(fullname_in_table, fullname_in_form)
        self.assertEqual(username_in_table, username_in_form)
        self.assertEqual(email_in_table, email_in_form)

        browser.find_element_by_id('cancel-button').click()
        print(colored('\ttest_4_correct_details: passed.', 'cyan'))
コード例 #23
0
    def test_1_no_network():
        print(colored('Running: test_1_no_network - estimate: 3s', 'yellow'))
        active_user_row = get_random_row_in_account_table()
        active_user_cols = active_user_row.find_elements_by_tag_name('td')
        click_action_button(active_user_cols)
        sleep(2*SLEEP_INTERVAL)

        browser.find_element_by_id('account-password').send_keys('testing')
        browser.find_element_by_id('confirm-password').send_keys('testing')

        prompt_to_disable_network()

        browser.find_element_by_id('save-button').send_keys(Keys.ENTER)
        sleep(9+SLEEP_INTERVAL)

        confirmation = browser.switch_to_alert()
        print(colored('\ttest_1_no_network: create failed - asserting...', 'blue'))
        assert 'Error occurred while updating account' in confirmation.text

        confirmation.accept()

        print(colored('\ttest_1_no_network: passed.', 'cyan'))
        prompt_to_enable_network_and_setup(browser, 'Administration/ManageUser')
コード例 #24
0
    def test_2_correct_details(self):
        print(
            colored('Running: test_2_correct_details - estimate: 24s',
                    'yellow'))

        for i in range(3):
            print(colored('\trandom node ' + str(i + 1), 'magenta'))

            node_row = get_random_table_row()
            node_cols = node_row.find_elements_by_tag_name('td')

            node_table_headers = get_table_headers()
            node_hex_in_table = node_cols[node_table_headers.index(
                'Hex. Address')].get_attribute('innerHTML')
            node_dec_in_table = node_cols[node_table_headers.index(
                'Dec. Address')].get_attribute('innerHTML')

            click_action_button(node_cols)

            node_detail_form = browser.find_element_by_xpath(
                '//div[@class="MuiFormControl-root"]')
            node_hex_in_form = node_detail_form.find_element_by_id(
                'hex-address').get_attribute('value')
            node_dec_in_form = node_detail_form.find_element_by_id(
                'dec-address').get_attribute('value')

            print(
                colored(
                    '\ttest_2_node_details: is correct node - asserting...',
                    'blue'))
            self.assertEqual(node_hex_in_table, node_hex_in_form)
            self.assertEqual(node_dec_in_table, node_dec_in_form)

            close_modal()

        print(colored('\ttest_2_correct_details: passed.', 'cyan'))
コード例 #25
0
    def test_2_correct_details(self):
        print(
            colored('Running: test_2_correct_details - estimate: 24s',
                    'yellow'))

        for i in range(3):
            print(colored('\trandom meter ' + str(i + 1), 'magenta'))

            meter_row = get_random_table_row()
            meter_cols = meter_row.find_elements_by_tag_name('td')

            meter_table_headers = get_table_headers()

            meter_serial_in_table = meter_cols[meter_table_headers.index(
                'Serial No.')].get_attribute('innerHTML')
            meter_endpoint_in_table = meter_cols[meter_table_headers.index(
                'End Point')].get_attribute('innerHTML')
            click_action_button(meter_cols)

            meter_detail_form = browser.find_element_by_xpath(
                '//div[@class="MuiFormControl-root"]')
            meter_serial_in_form = meter_detail_form.find_element_by_id(
                'serial-number').get_attribute('value')
            meter_endpoint_in_form = meter_detail_form.find_element_by_id(
                'endpoint-address').get_attribute('value')

            print(
                colored(
                    '\ttest_2_correct_details: is correct meter - asserting...',
                    'blue'))
            self.assertEqual(meter_serial_in_table, meter_serial_in_form)
            self.assertEqual(meter_endpoint_in_table, meter_endpoint_in_form)

            close_modal()

        print(colored('\ttest_2_correct_details: passed.', 'cyan'))
コード例 #26
0
    def test_3_confirm_success():
        print(
            colored('Running: test_2_confirm_no_network - estimate: 20s',
                    'yellow'))
        account_table_headers = get_table_headers()

        for i in range(2):
            print(colored('\trandom account ' + str(i + 1), 'magenta'))
            active_user_row = get_random_row_in_account_table()
            active_user_cols = active_user_row.find_elements_by_tag_name('td')
            click_action_button(active_user_cols)

            browser.find_element_by_id('delete-button').send_keys(Keys.ENTER)
            sleep(SLEEP_INTERVAL)
            browser.switch_to_alert().accept()
            sleep(2 * SLEEP_INTERVAL)

            active_users_table = browser.find_element_by_xpath(
                '//tbody[@class="MuiTableBody-root"]')
            active_users_rows = active_users_table.find_elements_by_tag_name(
                'tr')
            active_users = [
                row for row in active_users_rows
                if len(row.find_elements_by_tag_name('td')) > 0
            ]

            user_names = []
            for user in active_users:
                user_names.append(
                    user.find_elements_by_tag_name('td')
                    [account_table_headers.index('Full Name')].get_attribute(
                        'innerHTML'))

            print(
                colored('\ttest_1_unconfirmed: active users - asserting...',
                        'blue'))
            assert active_user_cols[account_table_headers.index(
                'Full Name')] not in user_names

            if len(
                    browser.find_elements_by_xpath(
                        '//tbody[@class="MuiTableBody-root"]')) > 1:
                inactive_users_table = browser.find_elements_by_xpath(
                    '//tbody[@class="MuiTableBody-root"]')[1]
                inactive_users_rows = inactive_users_table.find_elements_by_tag_name(
                    'tr')
                inactive_users = [
                    row for row in inactive_users_rows
                    if len(row.find_elements_by_tag_name('td')) > 0
                ]

                in_user_names = []
                for user in inactive_users:
                    in_user_names.append(
                        user.find_elements_by_tag_name('td')[
                            account_table_headers.index(
                                'Full Name')].get_attribute('innerHTML'))

                print(
                    colored(
                        '\ttest_1_unconfirmed: inactive users - asserting...',
                        'blue'))
                assert active_user_cols[account_table_headers.index(
                    'Full Name')] in in_user_names

            print(colored('\ttest_1_unconfirmed: passed.', 'cyan'))
コード例 #27
0
    def test_1_unconfirmed(self):
        print(colored('Running: test_1_unconfirmed - estimate: 3s', 'yellow'))
        account_table_headers = get_table_headers()

        active_user_row = get_random_row_in_account_table()
        active_user_cols = active_user_row.find_elements_by_tag_name('td')
        click_action_button(active_user_cols)

        browser.find_element_by_id('delete-button').send_keys(Keys.ENTER)
        sleep(SLEEP_INTERVAL)

        confirmation = browser.switch_to_alert()
        print(
            colored('\ttest_1_unconfirmed: cancel deletion - asserting...',
                    'blue'))
        self.assertEqual(
            confirmation.text, 'Delete the account ' +
            active_user_cols[account_table_headers.index('Full Name')] +
            '. Continue?')

        active_users_table = browser.find_element_by_xpath(
            '//tbody[@class="MuiTableBody-root"]')
        active_users_rows = active_users_table.find_elements_by_tag_name('tr')
        active_users = [
            row for row in active_users_rows
            if len(row.find_elements_by_tag_name('td')) > 0
        ]

        user_names = []
        for user in active_users:
            user_names.append(
                user.find_elements_by_tag_name('td')[
                    account_table_headers.index('Full Name')].get_attribute(
                        'innerHTML'))

        print(
            colored('\ttest_1_unconfirmed: active users - asserting...',
                    'blue'))
        assert active_user_cols[account_table_headers.index(
            'Full Name')] in user_names

        if len(
                browser.find_elements_by_xpath(
                    '//tbody[@class="MuiTableBody-root"]')) > 1:
            inactive_users_table = browser.find_elements_by_xpath(
                '//tbody[@class="MuiTableBody-root"]')[1]
            inactive_users_rows = inactive_users_table.find_elements_by_tag_name(
                'tr')
            inactive_users = [
                row for row in inactive_users_rows
                if len(row.find_elements_by_tag_name('td')) > 0
            ]

            in_user_names = []
            for user in inactive_users:
                in_user_names.append(
                    user.find_elements_by_tag_name('td')
                    [account_table_headers.index('Full Name')].get_attribute(
                        'innerHTML'))

            print(
                colored('\ttest_1_unconfirmed: inactive users - asserting...',
                        'blue'))
            assert active_user_cols[account_table_headers.index(
                'Full Name')] not in in_user_names

        print(colored('\ttest_1_unconfirmed: passed.', 'cyan'))