def run_alarms(self, driver, test_log): gui_lib = Utils(driver) self.login_manager.login() test_log.start('Alarms') test_helper = TestHelper(test_log, driver) driver.switch_to_default_content() gui_lib.click_element('menu_node_status') gui_lib.click_element('menu_node_alarms') driver.switch_to_frame('frame_content') # t = driver.find_element(By.XPATH, "//body/fieldset/legend").text # print('test', t) buttons = driver.find_elements_by_tag_name('button') # try test for visibility on the function below as it finds the buttons # before they are onscreen # (EC.visibility_of_element_located( WebDriverWait(driver, 20).until(EC.presence_of_all_elements_located((By.TAG_NAME, 'button'))) # check that there are 3 buttons test_helper.assert_true(len(buttons) != 3, 'Not all buttons displayed', 'Check that all buttons displayed') # test that the buttons have text on them for btn in buttons: test_helper.assert_true(len(btn.text.strip()) == 0, 'No text on button', 'Check buttons have text') print(len(btn.text.strip())) # test_log.close() self.login_manager.logout()
def run_poe(self, driver, test_log): self.login_manager.login() gui_lib = Utils(driver) test_helper = TestHelper(test_log, driver) driver.switch_to_default_content() gui_lib.click_element('menu_node_system_tree') gui_lib.click_element('menu_node_poe_config') test_log.start('Power Over Ethernet') # gui_lib.find_element_by_id(driver, "PoEConfigWidget1_TW_table1") failure_count = 0 driver.switch_to_frame("frame_content") table_element = "PoEConfigWidget1_TW_table" WebDriverWait(driver, 30).until(EC.visibility_of_element_located((By.ID, table_element))) table = driver.find_element_by_id(table_element) headers = table.find_elements_by_tag_name('th') test_helper.assert_true(len(headers) == 0, 'Expected Headers, got None', 'Testing Headers') # insert error to test. Uncomment when needed # driver.execute_script("document.getElementById('PoEConfigWidget1_TW_13_description').innerHTML=\"\";") interface = table.find_element_by_id("PoEConfigWidget1_TW_13_description").text interface_len = len(interface) test_helper.assert_true(len(interface) <= 0, 'Expected Interface length > 0', 'Testing Interfaces') time.sleep(2) self.login_manager.logout()
def run_port_manager(self, driver, test_log): gui_lib = Utils(driver) self.login_manager.login() test_log.start('Port Manager') test_helper = TestHelper(test_log, driver) driver.switch_to_default_content() gui_lib.click_element('menu_node_ethernet_tree') gui_lib.click_element('menu_node_ethernet') # WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "menu_node_10"))) driver.switch_to_frame('frame_content') try: WebDriverWait(driver, 30).until( EC.visibility_of_element_located((By.ID, 'PortSettingsWidget1intSet_TW_table'))) except TimeoutException: test_log.log_info('TimeoutException while waiting for Port Settings table') table = driver.find_element_by_id('PortSettingsWidget1intSet_TW_table') headers = table.find_elements_by_tag_name('th') headers_list = [] headers_arr = ['', 'Status1', 'Port', 'Enable', 'Description', 'Speed - Duplex', 'Default\nUser Priority', 'MAC Address', 'MTU'] header_ids = ['PortSettingsWidget1intSet_TW_table_header_entity_index', 'PortSettingsWidget1intSet_TW_table_header_operational_status', 'PortSettingsWidget1intSet_TW_table_header_port', 'PortSettingsWidget1intSet_TW_table_header_admin_status', 'PortSettingsWidget1intSet_TW_table_header_description', 'PortSettingsWidget1intSet_TW_table_header_user_duplex', 'PortSettingsWidget1intSet_TW_table_header_priority', 'PortSettingsWidget1intSet_TW_table_header_mac', 'PortSettingsWidget1intSet_TW_table_header_mtu'] test = Utils.build_inner_html_array(Utils.build_id_array(table)) # driver.execute_script(test) # these tests only check that headers are displayed. Wont flag if there are any missing, # the order incorrect etc. It is only a all or none deal for header in headers: headers_list.append(header.text) # uncomment to remove headers for testing # for header in test: # driver.execute_script(header) for i in range(len(headers_list)): header = headers_list[i] header_text_len = len(header) test_helper.assert_true(headers[i].text != header, 'Expected ' + header + ' to be > 0 but was ' + str(header_text_len), 'Ensure ' + header + ' visible') rows = table.find_elements_by_tag_name('tr') test_helper.assert_true(len(rows) <= 0, str(len(rows)) + ' Port Settings rows displayed ', 'Ensure Port Settings rows displayed ') self.login_manager.logout()
def run_system_information(self, driver, test_log): gui_lib = Utils(driver) self.login_manager.login() usr = "******" pw = "admin123" timetup = time.localtime() iso = time.strftime('%Y-%m-%d %H:%M:%S ', timetup) print "=====", iso, "=====" test_log.start('System Information') test_helper = TestHelper(test_log, driver) driver.switch_to_default_content() gui_lib.click_element('menu_node_system_tree') gui_lib.click_element('menu_node_system_info') driver.switch_to_frame("frame_content") table = driver.find_element_by_id("SystemInformationWidget1_TW_table") WebDriverWait(table, 10).until(EC.presence_of_element_located((By.ID, "SystemInformationWidget1_TW_0"))) headers = table.find_elements_by_tag_name('th') test_helper.assert_true(len(headers) == 0, 'Expected Headers, got None', 'Testing Headers') # hwVersion = table.find_element_by_id('SystemInformationWidget1_TW_0_1') # driver.execute_script("document.getElementById('SystemInformationWidget1_TW_0_1_renderer').innerHTML=\"\";") # hwVersionLen = len(hwVersion.text) # testHelper.assertTrue(len(hwVersion.text) > 0, 'Expected Headers, got None', 'Testing Headers') # assert hwVersionLen > 0, ('Expected length of Hardware Version to be greater than zero but was ', hwVersionLen) sw_version = table.find_element_by_id('SystemInformationWidget1_TW_1_1') # driver.execute_script("document.getElementById('SystemInformationWidget1_TW_1_1').innerHTML=\"\";") test_helper.assert_true(len(sw_version.text) == 0, 'Expected SW Version to be > 0', 'Testing SW Version Length') # assert swVersionLen > 0, ('Expected length of Software Version to be greater than zero but was ', swVersionLen) # firmVersion = table.find_element_by_id('SystemInformationWidget1_TW_2_1') # firmVersionLen = len(firmVersion.text) # assert firmVersionLen > 0, ('Expected length of Firmware Version to be greater than zero but was ', firmVersionLen) time.sleep(2) self.login_manager.logout()
def run_system_about(self, driver, test_log): gui_lib = Utils(driver) self.login_manager.login() test_log.start('System About') test_helper = TestHelper(test_log, driver) driver.switch_to_default_content() # WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "menu_node_7_tree"))) # driver.find_element_by_id("menu_node_7_tree").click() # time.sleep(2) # WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "menu_node_10"))) gui_lib.click_element("top_menu_help") gui_lib.click_element("help_about") original_window_handle = driver.current_window_handle driver.switch_to_window(driver.window_handles[1]) # about = driver.find_element(By.XPATH, "//body/fieldset/legend").text # assert about == "About", ("Expected About but got ", about) title = 'Aviat Networks Converged Transport Router' # webTitle = driver.find_element_by_xpath('//body/div/div/h3').text # assert title == webTitle, ('Expected ', title, ' but got ', webTitle) # # # WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, 'licenses'))) # time.sleep(2) licenses = gui_lib.find_element('licenses') # driver.execute_script("document.getElementById('licenses').innerHTML=\"\";") test_helper.assert_true(len(licenses.text) == 0, 'Expected SW Version to be > 0', 'Checking Licenses text not empty') driver.close() driver.switch_to_window(original_window_handle) time.sleep(2) self.login_manager.logout()
def run_sensors(self, driver, test_log): gui_lib = Utils(driver) self.login_manager.login() test_log.start('Sensors') test_helper = TestHelper(test_log, driver) driver.switch_to_default_content() gui_lib.click_element('menu_node_sensors') driver.switch_to_frame('frame_content') title = driver.find_element(By.XPATH, "//body/fieldset/legend").text test_helper.assert_true(len(title) == 0, 'Expected page title, got None', 'Test page title is displayed') table = gui_lib.find_element_by_id('tableWidget1_table') # find the table header as a delay driver.find_element_by_id('tableWidget1_table_header') table_rows = table.find_elements_by_tag_name('tr') print('table_rows', table_rows) self.login_manager.logout()
def run_date_time(self, driver, test_log): gui_lib = Utils(driver) self.login_manager.login() test_log.start('Date Time') test_helper = TestHelper(test_log, driver) failure_count = 0 driver.switch_to_default_content() gui_lib.click_element('menu_node_system_tree') gui_lib.click_element('menu_node_date_time') # gui_lib.click_element(driver, "menu_node_9") driver.switch_to_frame("frame_content") table = driver.find_element_by_id("DateTimeWidget1_TW_table") WebDriverWait(table, 20).until( EC.presence_of_element_located((By.CLASS_NAME, "TableWidget_verticalTableHeading"))) headers = table.find_elements_by_class_name('TableWidget_verticalTableHeading') test_helper.assert_true(len(headers) == 0, 'Expected Headers, got None', 'Testing Headers') # driver.execute_script("document.getElementById('DateTimeWidget1_TW_1_1').innerHTML=\"\";") mycalendar = table.find_element_by_id('DateTimeWidget1_TW_1_1') test_helper.assert_true(len(mycalendar.text) <= 0, 'No DateTimeWidget displayed', 'Testing DateTime widget') # driver.execute_script("document.getElementById('DateTimeWidget1_TW_3_1').innerHTML=\"\";") time_zone = table.find_element_by_id('DateTimeWidget1_TW_3_1') test_helper.assert_true(len(time_zone.text) <= 0, 'Expected TimeZone length > 0', 'Testing Timezone') # testLog.end_log2() self.login_manager.logout()
def run_event_log(self, driver, test_log): gui_lib = Utils(driver) self.login_manager.login() test_log.start('EventLog') test_helper = TestHelper(test_log, driver) driver.switch_to_default_content() gui_lib.click_element('menu_node_system_tree') gui_lib.click_element('menu_node_status') gui_lib.click_element('menu_node_event_log') driver.switch_to_frame('frame_content') table = driver.find_element_by_id('EventBrowserWidget1_table') headers = table.find_elements_by_tag_name('th') headers_list = [] for header in headers: print('headers', header.text) headers_list.append(header.text) for i in range(len(headers)): header = headers[i].text header_text_len = len(header) test_helper.assert_true(header_text_len <= 0, 'Expected ' + header + ' to be > 0 but was ' + str(header_text_len), 'Ensure ' + header + ' visible') sleep(10) rows = table.find_elements_by_tag_name('tr') test_helper.assert_true(len(rows) <= 0, str(len(rows)) + ' Event Log rows displayed ', 'Ensure Event Log rows displayed ') # test_log.close() self.login_manager.logout()