예제 #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'))
    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_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'))
예제 #4
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'))
예제 #5
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
예제 #6
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
예제 #7
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
예제 #8
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'))
예제 #9
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
예제 #10
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'))
예제 #11
0
    def test_3_commands_columns(self):
        print(colored('Running: test_3_commands_columns - estimate: 5s', 'yellow'))
        commands_table_headers = get_table_headers()

        for i in range(2):
            print(colored('\trandom commands ' + str(i + 1), 'magenta'))
            commands_row = get_random_table_row()
            commands_cols = commands_row.find_elements_by_tag_name('td')

            for col in commands_table_headers:
                col_data = commands_cols[commands_table_headers.index(col)].get_attribute('innerHTML')
                has_data = (col == 'Command' or col == 'Type') and len(col_data) > 0 or len(col_data) >= 0

                print(colored('\ttest_3_commands_columns: column "' + col + '" - asserting...', 'blue'))
                self.assertTrue(has_data)

        print(colored('\ttest_3_commands_columns: passed.', 'cyan'))
예제 #12
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'))
예제 #13
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')
예제 #14
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'))
    def test_3_search_success(self):
        print(
            colored('Running: test_3_search_success - estimate: 13s',
                    'yellow'))
        search_form = SearchForm()
        search_form.form_clear_button.send_keys(Keys.ENTER)
        gateway_table_headers = get_table_headers()

        keyword = ''
        for i in range(5):
            random_row = get_random_table_row()
            cols = random_row.find_elements_by_tag_name('td')
            keyword += (cols[gateway_table_headers.index(
                'Imei')].get_attribute('innerHTML') + ",")

        keyword = keyword[:-1]

        search_form.keyword_input.send_keys(keyword)
        browser.execute_script('arguments[0].click()',
                               search_form.search_fields[0])

        search_form.search_button.send_keys(Keys.ENTER)

        sleep(2 * SLEEP_INTERVAL)
        results = browser.find_elements_by_xpath(
            '//tbody[@class="MuiTableBody-root"]/tr')
        result_imeis = []
        for result in results:
            cols = result.find_elements_by_tag_name('td')
            if len(cols) != 0:
                result_imeis.append(cols[gateway_table_headers.index(
                    'Imei')].get_attribute('innerHTML'))

        keyword_imeis = keyword.split(',')
        print(
            colored('\ttest_3_search_success: matching results - asserting...',
                    'blue'))
        self.assertEqual(keyword_imeis.sort(), result_imeis.sort())

        print(colored('\ttest_3_search_success: passed.', 'cyan'))
예제 #16
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'))
예제 #17
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'))