def test_2_no_primary_key():
        print(
            colored('Running: test_2_no_primary_key - estimate: 45s',
                    'yellow'))

        for i in range(3):
            print(colored('\tnew gateway ' + str(i + 1), 'magenta'))
            click_fab_button()
            clear_inputs(['gateway-imei'], 'id')

            click_save_button()
            sleep(3 * SLEEP_INTERVAL)
            confirmation = browser.switch_to_alert()

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

            confirmation.accept()
            close_modal()
            sleep(2 * SLEEP_INTERVAL)

        print(colored('\ttest_2_no_primary_key: passed.', 'cyan'))
    def login_user(browser, credentials):
        login_btn = browser.find_element_by_css_selector("button[type='submit']")

        username_input = browser.find_element_by_id('username')
        password_input = browser.find_element_by_id('password')

        clear_inputs(['username', 'password'], 'id')

        username_input.send_keys(credentials['username'])
        password_input.send_keys(credentials['password'])

        login_btn.click()
    def test_1_correct_credentials():
        print(colored('Running: test_1_correct_credentials - estimate: 2s', 'yellow'))

        clear_inputs(['username', 'password'], 'id')
        Root.login_user(browser, {'username': '******', 'password': '******'})

        print(colored('\ttest_1_correct_credentials: login successful - asserting...', 'blue'))
        assert "No user in Juice matches the login credentials." not in browser.page_source
        assert "Username and Password are required." not in browser.page_source

        # check for user menu

        print(colored('\ttest_1_correct_credentials: passed.', 'cyan'))
    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_2_missing_inputs(self, form):
        print(
            colored('Running: test_2_empty_fields - estimate: 3m 30s',
                    'yellow'))

        clear_inputs(['username', 'password'], 'id')
        form.login_button.send_keys(Keys.ENTER)

        print(
            colored('\ttest_2_empty_fields: all fields empty - asserting...',
                    'blue'))
        try:
            assert_checking(self, 'Username and Password are required.')
        except AssertionError:
            assert_checking(self, 'No record in Juice matches the data.')

        form.username_input.send_keys('testing')
        form.login_button.send_keys(Keys.ENTER)

        print(
            colored('\ttest_2_empty_fields: password empty - asserting...',
                    'blue'))
        try:
            assert_checking(self, 'Username and Password are required.')
        except AssertionError:
            assert_checking(self, 'No record in Juice matches the data.')

        clear_inputs(['username', 'password'], 'id')
        form.password_input.send_keys('testing')
        form.login_button.send_keys(Keys.ENTER)

        print(
            colored('\ttest_2_empty_fields: username empty - asserting...',
                    'blue'))
        try:
            assert_checking(self, 'Username and Password are required.')
        except AssertionError:
            assert_checking(self, 'No record in Juice matches the data.')

        print(colored('\ttest_2_empty_fields: passed.', 'cyan'))
    def test_3_incorrect_credentials(self, form):
        print(
            colored('Running: test_3_incorrect_credentials - estimate: 2m 10s',
                    'yellow'))

        print(
            colored(
                '\ttest_3_incorrect_credentials: both fields incorrect - asserting...',
                'blue'))
        clear_inputs(['username', 'password'], 'id')
        Root.login_user(browser, {
            'username': faker.last_name(),
            'password': faker.word()
        })
        try:
            assert_checking(self,
                            'No user in Juice matches the login credentials.')
        except AssertionError:
            assert_checking(self, 'No record in Juice matches the data.')

        print(
            colored(
                '\ttest_3_incorrect_credentials: password incorrect - asserting...',
                'blue'))
        clear_inputs(['username', 'password'], 'id')
        Root.login_user(browser, {
            'username': '******',
            'password': faker.word()
        })
        try:
            assert_checking(self,
                            'No user in Juice matches the login credentials.')
        except AssertionError:
            assert_checking(self, 'No record in Juice matches the data.')

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