def test_3_device_model(self):
        print(colored('Running: test_3_device_model - estimate: 57s',
                      'yellow'))

        for i in range(3):
            print(colored('\trandom node ' + str(i + 1), 'magenta'))
            updated_hex = get_random_node()
            random_model_value = pick_random_dropdown_item('device-model')
            click_update_button()

            print(
                colored('\ttest_3_device_model: confirm update - asserting...',
                        'blue'))
            assert "The AMR Device with Hex. Address " + updated_hex + " has been updated successfully." in browser.page_source

            get_back_previously_updated_node(updated_hex)

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

            close_modal()

        print(colored('\ttest_3_device_model: passed.', 'cyan'))
    def test_4_dates():
        print(colored('Running: test_4_dates - estimate: 57s', 'yellow'))

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

            installed_on_input = browser.find_element_by_id('installed-on')
            serviced_on_input = browser.find_element_by_id('serviced-on')

            installed_on_input.send_keys(date.today().strftime("%d/%m/%Y"))
            serviced_on_input.send_keys(date.today().strftime("%d/%m/%Y"))

            sleep(SLEEP_INTERVAL)
            click_update_button()

            print(
                colored('\ttest_4_dates: confirm delete - asserting...',
                        'blue'))
            assert "The AMR Device with Hex. Address " + updated_serial + " has been updated successfully." in browser.page_source

            # get_back_previously_updated_node(updated_serial)
            #
            # new_installed_on = browser.find_element_by_id('installed-on').get_property('value')
            # new_activated_on = browser.find_element_by_id('activated-on').get_property('value')
            #
            # print(colored('\ttest_4_dates: is dates correct - asserting...', 'blue'))
            # self.assertEqual(new_installed_on, date.today().strftime("%d/%m/%Y"))
            # self.assertEqual(new_activated_on, date.today().strftime("%d/%m/%Y"))
            #
            # close_modal()

        print(colored('\ttest_4_dates: passed.', 'cyan'))
    def test_3_device_model(self):
        print(colored('Running: test_3_device_model - estimate: 57s',
                      'yellow'))

        for i in range(3):
            print(colored('\trandom gateway ' + str(i + 1), 'magenta'))
            updated_imei = get_random_gateway()
            gateway_detail_form = browser.find_element_by_xpath(
                '//div[@class="MuiFormControl-root"]')
            device_model_dropdown = gateway_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"]/li')
            random_device_model = get_random_dropdown_item(device_model_items)
            random_device_model.click()
            click_update_button()

            print(
                colored('\ttest_3_device_model: confirm update - asserting...',
                        'blue'))
            assert "The selected gateway with IMEI " + updated_imei + " has been updated successfully." in browser.page_source

            get_back_previously_updated_gateway(updated_imei)
            close_modal()

        print(colored('\ttest_3_device_model: passed.', 'cyan'))
    def test_5_active_switch():
        print(
            colored('Running: test_5_active_switch - estimate: 57s', 'yellow'))

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

            active_switch = browser.find_element_by_id('is-active')
            active_switch.click()
            sleep(SLEEP_INTERVAL)
            click_update_button()
    def test_2_missing_primary_key():
        print(colored('Running: test_2_missing_primary_key - estimate: 27s', 'yellow'))

        for i in range(3):
            print(colored('\trandom command ' + str(i + 1), 'magenta'))
            get_random_command()
            clear_inputs(['command-syntax'], 'id')
            click_update_button()

            confirmation = browser.switch_to_alert()

            print(colored('\ttest_2_missing_primary_key: confirmation dialog - asserting...', 'blue'))
            assert "Error occurred while updating command" in confirmation.text

            confirmation.accept()
            close_modal()

        print(colored('\ttest_2_missing_primary_key: passed.', 'cyan'))
    def test_1_no_network():
        print(colored('Running: test_1_no_network - estimate: 11s', 'yellow'))
        get_random_gateway()
        prompt_to_disable_network()
        click_update_button()
        sleep(9 + SLEEP_INTERVAL)

        confirmation = browser.switch_to_alert()

        print(
            colored('\ttest_1_no_network: confirmation dialog - asserting...',
                    'blue'))
        assert "Error occurred while updating gateway" in confirmation.text

        confirmation.accept()
        close_modal()

        print(colored('\ttest_1_no_network: passed.', 'cyan'))
        prompt_to_enable_network_and_setup(browser, 'Factory/ManageGateways')
    def test_1_no_network():
        print(colored('Running: test_1_no_network - estimate: 27s', 'yellow'))
        prompt_to_disable_network()

        for i in range(2):
            print(colored('\trandom command ' + str(i + 1), 'magenta'))
            get_random_command()
            click_update_button()
            sleep(9+SLEEP_INTERVAL)

            confirmation = browser.switch_to_alert()

            print(colored('\ttest_1_no_network: confirmation dialog - asserting...', 'blue'))
            assert "Error occurred while updating command" in confirmation.text

            confirmation.accept()
            close_modal()

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

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

            confirmation = browser.switch_to_alert()

            print(
                colored(
                    '\ttest_1_no_network: confirmation dialog - asserting...',
                    'blue'))
            assert "Error occurred while updating device" in confirmation.text

            confirmation.accept()
            close_modal()

        print(colored('\ttest_1_no_network: passed.', 'cyan'))
        prompt_to_enable_network_and_setup(browser, 'Factory/ManageDevice')
    def test_3_command_type(self):
        print(colored('Running: test_3_command_model - estimate: 57s', 'yellow'))

        for i in range(3):
            print(colored('\trandom command ' + str(i + 1), 'magenta'))
            updated_cmd = get_random_command()
            random_model_value = pick_random_dropdown_item('device-model')
            random_type_value = pick_random_dropdown_item('command-type')
            click_update_button()

            print(colored('\ttest_3_command_model: confirm update - asserting...', 'blue'))
            assert "The selected command has been updated successfully." in browser.page_source

            get_back_previously_updated_command(updated_cmd)

            updated_command_model = random_model_value # browser.find_element_by_id('device-model').get_attribute('innerHTML')
            updated_command_type = random_type_value # browser.find_element_by_id('command-type').get_attribute('innerHTML')
            print(colored('\ttest_3_command_model: command type selected - asserting...', 'blue'))
            self.assertEqual(random_model_value, updated_command_model)
            self.assertEqual(random_type_value, updated_command_type)

            close_modal()

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