示例#1
0
    def test_2_page_content(self):
        print(colored('Running: test_2_page_content - estimate: 2s', 'yellow'))

        print(
            colored('\ttest_2_page_content: list container - asserting...',
                    'blue'))
        sleep(2 * SLEEP_INTERVAL)
        self.assertEqual(check_existence('account-lists'), True)

        print(
            colored('\ttest_2_page_content: account form - asserting...',
                    'blue'))
        self.assertEqual(
            check_existence(
                '//div[@class="MuiFormControl-root MuiFormControl-fullWidth"]',
                is_id=False), True)

        account_list_container = browser.find_element_by_id('account-lists')
        account_lists = account_list_container.find_elements_by_xpath(
            '//tbody[@class="MuiTableBody-root"]')

        print(
            colored('\ttest_2_page_content: list count - asserting...',
                    'blue'))
        self.assertGreaterEqual(len(account_lists), 1)

        print(colored('\ttest_2_page_content: passed.', 'cyan'))
    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'))
示例#3
0
    def test_1_commands_list_no_network(self):
        print(colored('Running: test_1_commands_list_no_network - estimate: 27s', 'yellow'))
        prompt_to_disable_network()

        browser.refresh()
        Root.navigate_to(browser, 'Administration/GatewayCommand')
        sleep(2*SLEEP_INTERVAL)

        print(colored('\ttest_1_commands_list_no_network: commands list no network - asserting...', 'blue'))
        self.assertTrue(check_existence('//div[@class="inform"]', is_id=False))
        self.assertFalse(check_existence('//tbody[@class="MuiTableBody-root"]', is_id=False))

        print(colored('\ttest_1_commands_list_no_network: passed.', 'cyan'))
        prompt_to_enable_network_and_setup(browser, 'Administration/GatewayCommand')
示例#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'))
    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'))
示例#6
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_3_delete_confirm_success(self):
        print(colored('Running: test_3_delete_confirm_success - estimate: 15s', 'yellow'))

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

            browser.switch_to_alert().accept()
            sleep(2*SLEEP_INTERVAL)

            print(colored('\ttest_3_delete_confirm_success: confirm delete - asserting...', 'blue'))
            assert "The Meter with Serial No. " + deleted_serial + " has been deleted successfully." in browser.page_source

            print(colored('\ttest_3_delete_confirm_success: check modal - asserting...', 'blue'))
            self.assertFalse(check_existence('//div[@class="MuiFormControl-root"]', is_id=False))

            meter_table_headers = get_table_headers()
            rows = browser.find_elements_by_xpath('//tbody[@class="MuiTableBody-root"]/tr')
            serials = []
            for row in rows:
                serials.append(row.find_elements_by_tag_name('td')[meter_table_headers.index('Serial No.')]
                               .get_attribute('innerHTML'))

            print(colored('\ttest_3_delete_confirm_success: check deleted serial - asserting...', 'blue'))
            assert deleted_serial not in serials

        print(colored('\ttest_3_delete_confirm_success: passed.', 'cyan'))
    def test_1_fields_availability(self):
        print(
            colored('Running: test_1_fields_availability - estimate: 2s',
                    'yellow'))

        username_input_existed = check_existence('username')
        password_input_existed = check_existence('password')
        login_button_existed = check_existence('login_btn')

        print(
            colored(
                '\ttest_1_fields_availability: check existence - asserting...',
                'blue'))
        self.assertEqual(username_input_existed, True)
        self.assertEqual(password_input_existed, True)
        self.assertEqual(login_button_existed, True)

        print(colored('\ttest_1_fields_availability: passed.', 'cyan'))
    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'))
示例#10
0
    def test_1_no_network(self):
        print(colored('Running: test_1_no_network - estimate: 11s', 'yellow'))
        prompt_to_disable_network()

        browser.refresh()
        Root.navigate_to(browser, 'Administration/ManageUser')
        sleep(9 + SLEEP_INTERVAL)

        print(colored('\ttest_1_no_network: no network - asserting...',
                      'blue'))
        self.assertEqual(check_existence('account_lists'), False)
        self.assertEqual(
            check_existence('//div[@class="inform"]', is_id=False), True)
        self.assertEqual(
            check_existence(
                '//div[@class="MuiFormControl-root MuiFormControl-fullWidth"]',
                is_id=False), True)

        print(colored('\ttest_1_no_network: passed.', 'cyan'))
        prompt_to_enable_network_and_setup(browser,
                                           'Administration/ManageUser')
    def test_1_gateways_list_no_network(self):
        print(
            colored('Running: test_1_gateways_list_no_network - estimate: 27s',
                    'yellow'))
        prompt_to_disable_network()

        browser.refresh()
        Root.navigate_to(browser, 'Factory/ManageGateways')
        sleep(9 + SLEEP_INTERVAL)

        print(
            colored(
                '\ttest_1_gateways_list_no_network: gateways list no network - asserting...',
                'blue'))
        self.assertTrue(check_existence('//div[@class="inform"]', is_id=False))
        self.assertFalse(
            check_existence('//tbody[@class="MuiTableBody-root"]',
                            is_id=False))
        self.assertFalse(check_existence('gateway-search-form'))

        print(colored('\ttest_1_gateways_list_no_network: passed.', 'cyan'))
        prompt_to_enable_network_and_setup(browser, 'Factory/ManageGateways')
    def test_1_delete_unconfirm(self):
        print(colored('Running: test_1_delete_unconfirm - estimate: 33s', 'yellow'))

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

            browser.switch_to_alert().dismiss()
            sleep(SLEEP_INTERVAL)

            print(colored('\ttest_1_delete_unconfirm: unconfirm delete - asserting...', 'blue'))
            self.assertTrue(check_existence('//div[@class="MuiFormControl-root"]', is_id=False))

            close_modal()

        print(colored('\ttest_1_delete_unconfirm: passed.', 'cyan'))
示例#13
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'))
示例#14
0
    def test_3_delete_confirm_success(self):
        print(
            colored('Running: test_3_delete_confirm_success - estimate: 15s',
                    'yellow'))

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

            browser.switch_to_alert().accept()
            sleep(2 * SLEEP_INTERVAL)

            print(
                colored(
                    '\ttest_3_delete_confirm_success: confirm delete - asserting...',
                    'blue'))
            assert "The selected gateway with IMEI " + deleted_imei + " has been deleted successfully." in browser.page_source

            print(
                colored(
                    '\ttest_3_delete_confirm_success: check modal - asserting...',
                    'blue'))
            self.assertFalse(
                check_existence('//div[@class="MuiFormControl-root"]',
                                is_id=False))

            gateway_table_headers = get_table_headers()
            rows = browser.find_elements_by_xpath(
                '//tbody[@class="MuiTableBody-root"]/tr')
            imeis = []
            for row in rows:
                imeis.append(
                    row.find_elements_by_tag_name('td')[
                        gateway_table_headers.index('Imei')].get_attribute(
                            'innerHTML'))

            print(
                colored(
                    '\ttest_3_delete_confirm_success: check deleted imei - asserting...',
                    'blue'))
            assert deleted_imei not in imeis

        print(colored('\ttest_3_delete_confirm_success: passed.', 'cyan'))
示例#15
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')
示例#16
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_1_search_form_elements(self):
        print(
            colored('Running: test_1_search_form_elements - estimate: 1s',
                    'yellow'))

        for element_id in SEARCH_FORM_IDs:
            print(
                colored(
                    '\ttest_1_search_form_elements: input "' + element_id +
                    '" existence - asserting...', 'blue'))
            self.assertTrue(check_existence(element_id))

        search_form = SearchForm()
        print(
            colored(
                '\ttest_1_search_form_elements: element status - asserting...',
                'blue'))
        self.assertFalse(search_form.inverted_input.is_selected())
        self.assertFalse(search_form.inactive_input.is_selected())
        self.assertFalse(search_form.search_button.is_enabled())

        print(colored('\ttest_1_search_form_elements: passed.', 'cyan'))
    def test_2_error_handling(self):
        print(
            colored('Running: test_2_error_handling - estimate: 13s',
                    'yellow'))

        search_form = SearchForm()
        search_form.keyword_input.send_keys(faker.word())
        sleep(SLEEP_INTERVAL)

        print(
            colored('\ttest_2_error_handling: alert message - asserting...',
                    'blue'))
        assert "At least 1 Search Field must be selected to perform search." in browser.page_source
        self.assertFalse(search_form.search_button.is_enabled())

        search_form.check_random_search_field()
        sleep(SLEEP_INTERVAL)

        print(
            colored('\ttest_2_error_handling: alert message - asserting...',
                    'blue'))
        assert "At least 1 Search Field must be selected to perform search." not in browser.page_source
        self.assertTrue(search_form.search_button.is_enabled())

        browser.execute_script('arguments[0].click()',
                               search_form.inverted_input)
        sleep(SLEEP_INTERVAL)

        print(
            colored('\ttest_2_error_handling: alert message - asserting...',
                    'blue'))
        assert "No date range to invert. Please set a date range first." in browser.page_source
        self.assertFalse(search_form.inverted_input.is_selected())
        self.assertTrue(search_form.search_button.is_enabled())

        search_form.date_from_input.send_keys(
            date.today().strftime("%d/%m/%Y"))
        browser.execute_script('arguments[0].click()',
                               search_form.inverted_input)
        sleep(SLEEP_INTERVAL)

        print(
            colored('\ttest_2_error_handling: alert message - asserting...',
                    'blue'))
        assert "No date range to invert. Please set a date range first." in browser.page_source
        self.assertFalse(search_form.inverted_input.is_selected())
        self.assertTrue(search_form.search_button.is_enabled())

        search_form.date_to_input.send_keys(date.today().strftime("%d/%m/%Y"))
        print(
            colored('\ttest_2_error_handling: alert message - asserting...',
                    'blue'))
        self.assertFalse(
            check_existence('//div[@class="alert alert-warning"]',
                            is_id=False))
        self.assertTrue(search_form.search_button.is_enabled())

        browser.execute_script('arguments[0].click()',
                               search_form.inverted_input)
        sleep(SLEEP_INTERVAL)

        print(
            colored('\ttest_2_error_handling: alert message - asserting...',
                    'blue'))
        assert "No date range to invert. Please set a date range first." in browser.page_source
        self.assertFalse(search_form.inverted_input.is_selected())
        self.assertTrue(search_form.search_button.is_enabled())

        search_form.form_clear_button.send_keys(Keys.ENTER)
        sleep(SLEEP_INTERVAL)

        print(
            colored('\ttest_2_error_handling: alert message - asserting...',
                    'blue'))
        self.assertFalse(search_form.search_button.is_enabled())

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

        print(
            colored('\ttest_2_error_handling: alert message - asserting...',
                    'blue'))
        assert "At least 1 Search Field must be selected to perform search." in browser.page_source
        self.assertFalse(search_form.search_button.is_enabled())

        search_form.date_from_input.send_keys(
            date.today().strftime("%d/%m/%Y"))
        search_form.date_to_input.send_keys(date.today().strftime("%d/%m/%Y"))

        print(
            colored('\ttest_2_error_handling: alert message - asserting...',
                    'blue'))
        assert "At least 1 Search Field must be selected to perform search." in browser.page_source
        self.assertFalse(search_form.search_button.is_enabled())

        # search_form.check_random_search_field()
        # search_form.date_to_input.send_keys('1-1-2000')
        #
        # print(colored('\ttest_2_error_handling: alert message - asserting...', 'blue'))
        # assert "Date From should not be greater than Date To. Please check date range." in browser.page_source
        # self.assertFalse(search_form.search_button.is_enabled())
        #
        # search_form.date_to_input.send_keys('1-1-1999')
        #
        # print(colored('\ttest_2_error_handling: alert message - asserting...', 'blue'))
        # assert "Date From should not be greater than Date To. Please check date range." not in browser.page_source
        # self.assertTrue(search_form.search_button.is_enabled())
        #
        # search_form.inverted_input.click()
        # search_form.date_to_input.send_keys('1-1-1999')
        #
        # print(colored('\ttest_2_error_handling: alert message - asserting...', 'blue'))
        # assert "Date From should not be greater than Date To. Please check date range." in browser.page_source
        # self.assertFalse(search_form.search_button.is_enabled())

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