def test_2_delete_confirm_no_network(): print( colored( 'Running: test_2_delete_confirm_no_network - estimate: 13s', 'yellow')) deleted_imei = get_random_gateway() prompt_to_disable_network() click_delete_button() confirmation = browser.switch_to_alert() print( colored( '\ttest_2_delete_confirm_no_network: confirm delete no network - asserting...', 'blue')) assert "The gateway with Imei " + deleted_imei + " will be lost permanently. Continue?" in confirmation.text confirmation.accept() sleep(9 + SLEEP_INTERVAL) deletion_result = browser.switch_to_alert() print( colored( '\ttest_2_delete_confirm_no_network: confirm delete no network - asserting...', 'blue')) assert "Error occurred while deleting gateway" in deletion_result.text confirmation.accept() sleep(SLEEP_INTERVAL) close_modal() print(colored('\ttest_2_delete_confirm_no_network: passed.', 'cyan')) prompt_to_enable_network_and_setup(browser, 'Factory/ManageGateways')
def test_4_dates(): print(colored('Running: test_4_dates - estimate: 57s', 'yellow')) for i in range(3): print(colored('\trandom gateway ' + str(i + 1), 'magenta')) updated_imei = get_random_gateway() installed_on_input = browser.find_element_by_id('installed-on') created_on_input = browser.find_element_by_id('created-on') updated_on_input = browser.find_element_by_id('updated-on') installed_on_input.send_keys(date.today().strftime("%d/%m/%Y")) created_on_input.send_keys(date.today().strftime("%d/%m/%Y")) updated_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 selected gateway with IMEI " + updated_imei + " has been updated successfully." in browser.page_source # get_back_previously_updated_gateway(updated_imei) # # 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_input_validations(): print( colored('Running: test_6_input_validations - estimate: 57s', 'yellow')) for i in range(3): print(colored('\trandom gateway ' + str(i + 1), 'magenta')) updated_imei = get_random_gateway()
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_2_missing_primary_key(): print( colored('Running: test_2_missing_primary_key - estimate: 27s', 'yellow')) for i in range(3): print(colored('\trandom gateway ' + str(i + 1), 'magenta')) get_random_gateway() clear_inputs(['gateway-imei'], '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 gateway" in confirmation.text confirmation.accept() close_modal() print(colored('\ttest_2_missing_primary_key: passed.', 'cyan'))
def test_1_delete_unconfirm(self): print( colored('Running: test_1_delete_unconfirm - estimate: 33s', 'yellow')) for i in range(3): print(colored('\trandom gateway ' + str(i + 1), 'magenta')) get_random_gateway() click_delete_button() 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'))
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'))