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_2_confirm_no_network(): print( colored('Running: test_2_confirm_no_network - estimate: 40s', 'yellow')) prompt_to_disable_network() for i in range(3): print(colored('\trandom account ' + str(i + 1), 'magenta')) active_user_row = get_random_row_in_account_table() active_user_cols = active_user_row.find_elements_by_tag_name('td') click_action_button(active_user_cols) browser.find_element_by_id('delete-button').send_keys(Keys.ENTER) sleep(SLEEP_INTERVAL) browser.switch_to_alert().accept() sleep(9 + SLEEP_INTERVAL) print( colored( '\ttest_2_confirm_no_network: deletion failed - asserting...', 'blue')) confirmation = browser.switch_to_alert() assert 'Error occurred while deleting account' in confirmation.text confirmation.accept() browser.find_element_by_id('cancel-button').send_keys(Keys.ENTER) sleep(SLEEP_INTERVAL) print(colored('\ttest_2_confirm_no_network: passed.', 'cyan')) prompt_to_enable_network_and_setup(browser, 'Administration/ManageUser')
def test_2_confirm_no_network(): print( colored('Running: test_2_confirm_no_network - estimate: 40s', 'yellow')) prompt_to_disable_network() inactive_user_row = get_random_row_in_account_table(active=False) inactive_user_cols = inactive_user_row.find_elements_by_tag_name('td') click_action_button(inactive_user_cols) sleep(SLEEP_INTERVAL) browser.switch_to_alert().accept() sleep(9 + SLEEP_INTERVAL) print( colored( '\ttest_2_confirm_no_network: revival failed - asserting...', 'blue')) confirmation = browser.switch_to_alert() assert 'Error occurred while reviving account' in confirmation.text confirmation.accept() print(colored('\ttest_2_confirm_no_network: passed.', 'cyan')) prompt_to_enable_network_and_setup(browser, 'Administration/ManageUser')
def test_2_delete_confirm_no_network(): print( colored( 'Running: test_2_delete_confirm_no_network - estimate: 27s', 'yellow')) prompt_to_disable_network() for i in range(2): print(colored('\trandom node ' + str(i + 1), 'magenta')) deleted_hex = get_random_node_and_delete() sleep(9 + SLEEP_INTERVAL) confirmation = browser.switch_to_alert() print( colored( '\ttest_2_delete_confirm_no_network: confirm delete no network - asserting...', 'blue')) assert "The device with Hex. Address " + deleted_hex + " will be lost permanently. Continue?" in confirmation.text confirmation.accept() sleep(2 * 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 device" 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/ManageDevice')
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_2_delete_confirm_no_network(): print( colored( 'Running: test_2_delete_confirm_no_network - estimate: 13s', 'yellow')) prompt_to_disable_network() command = get_random_command_and_delete() confirmation = browser.switch_to_alert() print( colored( '\ttest_2_delete_confirm_no_network: confirm delete no network - asserting...', 'blue')) assert "The command " + command + " 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 command" 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, 'Administration/GatewayCommand')
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 test_5_clashed_primary_key(): print( colored('Running: test_5_clashed_primary_key - estimate: 27s', 'yellow')) hex = get_random_table_data('Hex. Address') click_fab_button() browser.find_element_by_id('device-name').send_keys('test name') browser.find_element_by_id('hex-address').send_keys(hex) browser.find_element_by_id('dec-address').send_keys('decimal') browser.find_element_by_id('serial-number').send_keys('test serial') browser.find_element_by_id('installed-on').send_keys( date.today().strftime("%d/%m/%Y")) browser.find_element_by_id('serviced-on').send_keys( date.today().strftime("%d/%m/%Y")) random_device_model = pick_random_dropdown_item('device-model') click_save_button() confirmation = browser.switch_to_alert() print( colored( '\ttest_5_clashed_primary_key: confirmation dialog - asserting...', 'blue')) assert "Error occurred while saving device" in confirmation.text confirmation.accept() close_modal() sleep(2 * SLEEP_INTERVAL)
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'))
def test_3_no_device_model(): print( colored('Running: test_3_no_device_model - estimate: 45s', 'yellow')) for i in range(3): print(colored('\tnew meter ' + str(i + 1), 'magenta')) click_fab_button() browser.find_element_by_id('serial-number').send_keys('testing' + str(i + 1)) click_save_button() confirmation = browser.switch_to_alert() print( colored( '\ttest_3_no_device_model: confirmation dialog - asserting...', 'blue')) assert "Error occurred while saving meter" in confirmation.text confirmation.accept() close_modal() sleep(2 * SLEEP_INTERVAL) print(colored('\ttest_3_no_device_model: passed.', 'cyan'))
def test_5_clashed_primary_key(): print( colored('Running: test_5_clashed_primary_key - estimate: 27s', 'yellow')) end_point = get_random_table_data('End Point') serial = get_random_table_data('Serial No.') click_fab_button() browser.find_element_by_id('meter-name').send_keys('testing name') browser.find_element_by_id('serial-number').send_keys(serial) browser.find_element_by_id('endpoint-address').send_keys(end_point) browser.find_element_by_id('pulse-weight').send_keys('1.23') browser.find_element_by_id('volume-unit').send_keys('GB') browser.find_element_by_id('pairing-status').send_keys( 'testing pairing status note') browser.find_element_by_id('installed-on').send_keys( date.today().strftime("%d/%m/%Y")) browser.find_element_by_id('activated-on').send_keys( date.today().strftime("%d/%m/%Y")) random_device_model = pick_random_dropdown_item('device-model') click_save_button() confirmation = browser.switch_to_alert() print( colored( '\ttest_5_clashed_serial: confirmation dialog - asserting...', 'blue')) assert "Error occurred while saving meter" in confirmation.text confirmation.accept() close_modal() sleep(2 * SLEEP_INTERVAL)
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'))
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')) prompt_to_disable_network() browser.find_element_by_id('save-button').send_keys(Keys.ENTER) sleep(9 + SLEEP_INTERVAL) confirmation = browser.switch_to_alert() print( colored('\ttest_1_no_network: create failed - asserting...', 'blue')) assert 'Error occurred while creating new account' in confirmation.text confirmation.accept() print(colored('\ttest_1_no_network: passed.', 'cyan')) prompt_to_enable_network_and_setup(browser, 'Administration/ManageUser')
def test_5_clashed_primary_key(): print( colored('Running: test_5_clashed_primary_key - estimate: 27s', 'yellow')) imei = get_random_table_data('Imei') click_fab_button() browser.find_element_by_id('gateway-imei').send_keys(imei) browser.find_element_by_id('gateway-name').send_keys('test name') browser.find_element_by_id('phone-number').send_keys('test phone') browser.find_element_by_id('hex-address').send_keys('hex address') browser.find_element_by_id('dec-address').send_keys('dec address') browser.find_element_by_id('ip-address').send_keys('ip address') browser.find_element_by_id('software-version').send_keys('sw version') browser.find_element_by_id('firmware-version').send_keys('fw version') browser.find_element_by_id('sim-serial').send_keys('sim serial') browser.find_element_by_id('sim-puk').send_keys('sim puk') 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_save_button() confirmation = browser.switch_to_alert() print( colored( '\ttest_5_clashed_serial: confirmation dialog - asserting...', 'blue')) assert "Error occurred while saving gateway" in confirmation.text confirmation.accept() close_modal() sleep(2 * SLEEP_INTERVAL)
def test_1_no_network(): print(colored('Running: test_1_no_network - estimate: 48s', 'yellow')) prompt_to_disable_network() click_fab_button() click_save_button() sleep(9 + SLEEP_INTERVAL) confirmation = browser.switch_to_alert() print( colored('\ttest_1_no_network: confirmation dialog - asserting...', 'blue')) assert "Error occurred while saving gateway" in confirmation.text confirmation.accept() print(colored('\ttest_1_no_network: passed.', 'cyan')) browser.refresh() 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_5_clashed_primary_key(): print(colored('Running: test_5_clashed_primary_key - estimate: 27s', 'yellow')) command = get_random_table_data('Command') click_fab_button() browser.find_element_by_id('command-name').send_keys('test name') browser.find_element_by_id('command-syntax').send_keys(command) pick_random_dropdown_item('device-model') pick_random_dropdown_item('command-type') browser.find_element_by_id('command-description').send_keys('command description testing') click_save_button() confirmation = browser.switch_to_alert() print(colored('\ttest_5_clashed_primary_key: confirmation dialog - asserting...', 'blue')) assert "Error occurred while saving command" in confirmation.text confirmation.accept() close_modal() sleep(2*SLEEP_INTERVAL)
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_1_no_network(): print(colored('Running: test_1_no_network - estimate: 3s', 'yellow')) active_user_row = get_random_row_in_account_table() active_user_cols = active_user_row.find_elements_by_tag_name('td') click_action_button(active_user_cols) sleep(2*SLEEP_INTERVAL) browser.find_element_by_id('account-password').send_keys('testing') browser.find_element_by_id('confirm-password').send_keys('testing') prompt_to_disable_network() browser.find_element_by_id('save-button').send_keys(Keys.ENTER) sleep(9+SLEEP_INTERVAL) confirmation = browser.switch_to_alert() print(colored('\ttest_1_no_network: create failed - asserting...', 'blue')) assert 'Error occurred while updating account' in confirmation.text confirmation.accept() print(colored('\ttest_1_no_network: passed.', 'cyan')) prompt_to_enable_network_and_setup(browser, 'Administration/ManageUser')
def test_1_no_network(): print(colored('Running: test_1_no_network - estimate: 45s', 'yellow')) prompt_to_disable_network() for i in range(3): print(colored('\tnew meter ' + str(i + 1), 'magenta')) click_fab_button() click_save_button() sleep(3 * SLEEP_INTERVAL) confirmation = browser.switch_to_alert() print( colored( '\ttest_1_no_network: confirmation dialog - asserting...', 'blue')) assert "Error occurred while saving meter" in confirmation.text confirmation.accept() close_modal() sleep(2 * SLEEP_INTERVAL) print(colored('\ttest_1_no_network: passed.', 'cyan')) prompt_to_enable_network_and_setup(browser, 'Factory/ManageMeter')
def test_3_confirm_success(): print( colored('Running: test_2_confirm_no_network - estimate: 20s', 'yellow')) account_table_headers = get_table_headers() for i in range(2): print(colored('\trandom account ' + str(i + 1), 'magenta')) active_user_row = get_random_row_in_account_table() active_user_cols = active_user_row.find_elements_by_tag_name('td') click_action_button(active_user_cols) browser.find_element_by_id('delete-button').send_keys(Keys.ENTER) sleep(SLEEP_INTERVAL) browser.switch_to_alert().accept() sleep(2 * SLEEP_INTERVAL) active_users_table = browser.find_element_by_xpath( '//tbody[@class="MuiTableBody-root"]') active_users_rows = active_users_table.find_elements_by_tag_name( 'tr') active_users = [ row for row in active_users_rows if len(row.find_elements_by_tag_name('td')) > 0 ] user_names = [] for user in active_users: user_names.append( user.find_elements_by_tag_name('td') [account_table_headers.index('Full Name')].get_attribute( 'innerHTML')) print( colored('\ttest_1_unconfirmed: active users - asserting...', 'blue')) assert active_user_cols[account_table_headers.index( 'Full Name')] not in user_names if len( browser.find_elements_by_xpath( '//tbody[@class="MuiTableBody-root"]')) > 1: inactive_users_table = browser.find_elements_by_xpath( '//tbody[@class="MuiTableBody-root"]')[1] inactive_users_rows = inactive_users_table.find_elements_by_tag_name( 'tr') inactive_users = [ row for row in inactive_users_rows if len(row.find_elements_by_tag_name('td')) > 0 ] in_user_names = [] for user in inactive_users: in_user_names.append( user.find_elements_by_tag_name('td')[ account_table_headers.index( 'Full Name')].get_attribute('innerHTML')) print( colored( '\ttest_1_unconfirmed: inactive users - asserting...', 'blue')) assert active_user_cols[account_table_headers.index( 'Full Name')] in in_user_names print(colored('\ttest_1_unconfirmed: passed.', 'cyan'))
def test_1_unconfirmed(self): print(colored('Running: test_1_unconfirmed - estimate: 3s', 'yellow')) account_table_headers = get_table_headers() active_user_row = get_random_row_in_account_table() active_user_cols = active_user_row.find_elements_by_tag_name('td') click_action_button(active_user_cols) browser.find_element_by_id('delete-button').send_keys(Keys.ENTER) sleep(SLEEP_INTERVAL) confirmation = browser.switch_to_alert() print( colored('\ttest_1_unconfirmed: cancel deletion - asserting...', 'blue')) self.assertEqual( confirmation.text, 'Delete the account ' + active_user_cols[account_table_headers.index('Full Name')] + '. Continue?') active_users_table = browser.find_element_by_xpath( '//tbody[@class="MuiTableBody-root"]') active_users_rows = active_users_table.find_elements_by_tag_name('tr') active_users = [ row for row in active_users_rows if len(row.find_elements_by_tag_name('td')) > 0 ] user_names = [] for user in active_users: user_names.append( user.find_elements_by_tag_name('td')[ account_table_headers.index('Full Name')].get_attribute( 'innerHTML')) print( colored('\ttest_1_unconfirmed: active users - asserting...', 'blue')) assert active_user_cols[account_table_headers.index( 'Full Name')] in user_names if len( browser.find_elements_by_xpath( '//tbody[@class="MuiTableBody-root"]')) > 1: inactive_users_table = browser.find_elements_by_xpath( '//tbody[@class="MuiTableBody-root"]')[1] inactive_users_rows = inactive_users_table.find_elements_by_tag_name( 'tr') inactive_users = [ row for row in inactive_users_rows if len(row.find_elements_by_tag_name('td')) > 0 ] in_user_names = [] for user in inactive_users: in_user_names.append( user.find_elements_by_tag_name('td') [account_table_headers.index('Full Name')].get_attribute( 'innerHTML')) print( colored('\ttest_1_unconfirmed: inactive users - asserting...', 'blue')) assert active_user_cols[account_table_headers.index( 'Full Name')] not in in_user_names print(colored('\ttest_1_unconfirmed: passed.', 'cyan'))