def configure_deny_inter_user_bridging_and_deny_local_routing(ap): import time myDevice = Device.getDeviceObject(ap) myDevice.receive("#") myDevice.transmit("show ap debug cloud-server") myDevice.transmit("configure terminal") # myDevice.receive("(config) #") time.sleep(8) myDevice.receive("#") myDevice.transmit("wlan ssid-profile em1") time.sleep(8) myDevice.receive("#") myDevice.transmit("deny-inter-user-bridging") time.sleep(8) myDevice.receive("#") myDevice.transmit("deny-local-routing") time.sleep(8) myDevice.receive("#") myDevice.transmit("end") time.sleep(8) myDevice.receive("#") myDevice.transmit("commit apply") time.sleep(8) myDevice.receive("#") myDevice.transmit("sh ru | inc deny") time.sleep(8) myDevice.receive("#")
def disconnect_client_from_ap(device): myDevice = Device.getDeviceObject(device) try: myDevice.disconnect_client_from_ap() except: myDevice.connect() myDevice.disconnect_client_from_ap()
def go_to_client_details_page(self, client): import pdb #pdb.set_trace() myDevice = Device.getDeviceObject(client) table = self.client_monitoring_table entries = table.find_elements_by_xpath( "//span[contains(@id,'clientsTable_macaddr_display_')]") for entry in entries: if entry.text == myDevice.get("mac"): entry.click() time.sleep(5) for i in range(1, 5): try: log.info("Checking Client Label in Clients Detail Page : %s" % self.client_details_page_label.text) if self.client_details_page_label.text == myDevice.get("mac"): break else: time.sleep(5) self.browser.refresh() except: time.sleep(5) self.browser.refresh() if not self.client_details_page_label.text == myDevice.get("mac"): raise AssertionError("NOT IN THE EXPECTED CLIENT PAGE")
def add_switch_and_assign_license(self,switch): myDevice = Device.getDeviceObject(switch) mac_address = myDevice.get("mac") activation_key = myDevice.get("activation_id") serial = myDevice.get("serial") self.clicking_switch_tab() device = self.browser._browser.find_element_by_xpath("//span[contains(.,'%s')]/../preceding-sibling::td[1]/input" %serial) if not device : logger.debug("DeviceManagementPage: Clicking on 'Add Device' button") self.add_device.click() logger.debug("DeviceManagementPage: Setting Cloud Activation Key") self.activation_key.set(activation_key) logger.debug("DeviceManagementPage: Setting Cloud Activation Key") self.device_mac_address.set(mac_address) logger.debug("DeviceManagementPage: Clicking on 'Add' button") self.add_button.click() self.browser.key_press(u'\ue00c') device.click() try: self.assigned_licence_button.click() assign = self.browser._browser.find_element_by_xpath("//a[@id='assign_0' and text()='Assign']") print assign raw_input('assign license') # assign.click() except: pass
def write_erase_all(device): myDevice = Device.getDeviceObject(device) myDevice.receive("#") myDevice.transmit("write erase all") myDevice.receive("\(y\/n\):") myDevice.transmit("y") output = myDevice.receive("#")
def move_device_to_group(self,group,device): ''' Move device from one one group to other . ''' myDevice = Device.getDeviceObject(device) if not "IAP" in device: logger.debug("ManageGroupPage: Click on switches_toggle") try: self.switches_toggle.click() self.switches_toggle.click() except: self.manage_button.click() self.switches_toggle.click() self.switches_toggle.click() device_name=myDevice.get("switch_name") else: self.browser._browser.find_element_by_xpath("//a[@id='toggle_vc']").click() device_name=myDevice.get("vc_name") logger.debug("ManageGroupPage: Select device") self.browser._browser.find_element_by_xpath("//span[contains(.,'%s')]/../preceding-sibling::td[1]/input" %device_name).click() logger.debug("ManageGroupPage: Clicking on 'Move' button ") self.move.click() self.buy_time() logger.debug("ManageGroupPage: Clicking on required 'group' ") group_obj = self.browser._browser.find_element_by_xpath("//span[contains(@id,'group_table_name') and contains(text(), '%s')]" % group) logger.info(group_obj) group_obj.click() logger.debug("ManageGroupPage: Clicking on 'Save' button ") self.save.click()
def assert_ap_name_present_in_ap_table(self, ap): myDevice = Device.getDeviceObject(ap) ap_name = myDevice.get("mac") ap_name_list = self.get_ap_names() if ap_name not in ap_name_list: raise AssertionError("IAP is not present in the AP Table of the report")
def test_ath_11302_check_non_default_values_cpu_util(self): myDevice = Device.getDeviceObject("IAP_1") vlan_id = myDevice.get("vlan") conf = self.config.config_vars system_page = self.LeftPanel.go_to_system_page() system_page.set_new_vc_name("IAP_1",conf.vc_name) system_page.set_new_vc_ip("IAP_1",conf.ip_add) system_page.set_non_default_values_cpu_util("IAP_1") system_page._save_settings() time.sleep(10) system_page.assert_system_page_vc_field_values("IAP_1","sh ru | inc name",conf.vc_name) system_page.assert_system_page_vc_field_values("IAP_1","sh ru | inc virtual",conf.ip_add) system_page.assert_system_page_vc_field_values("IAP_1","sh ru | inc time","Pacific-Time -07") system_page.assert_system_page_vc_field_values("IAP_1","sh ru | inc ntp",conf.ntp_server) system_page.assert_system_page_vc_field_values("IAP_1","sh ru | inc band","5ghz") system_page.assert_system_page_vc_field_values("IAP_1","sh ru | inc vlan",vlan_id) system_page.assert_system_page_vc_field_values("IAP_1","sh ru | inc cpu","dynamic-cpu-mgmt enable") time.sleep(10) DeviceLibrary.factoryReset("IAP_1") time.sleep(10) DeviceLibrary.getPrompt("IAP_1") DeviceLibrary.reconnect("IAP_1") time.sleep(90) inner_left_panel = self.TopPanel.click_slider_icon() inner_left_panel.click_expand_default_group_icon() inner_left_panel.select_vc("IAP_1") inner_left_panel.select_country_code(self.config.config_vars.country_india) # system_page.setting_original_vc_name("IAP_1",conf.vc_name) // After factory_reset, automatically take default name on system page # system_page.setting_original_vc_ip("IAP_1",conf.ip_add) // After factory_reset, automatically take default ip on system page system_page.set_cpu_util_default_values()
def verify_flagged_ap_table(self, ap): from Device_Module.ObjectModule import Device myDevice = Device.getDeviceObject(ap) table = self.access_points_flagged_ap_table entries = table.find_elemens_by_id("flaggedAPsTable_name_display_0") if not myDevice.get("mac") in entries: raise AssertionError("AP IS NOT IN FLAGGED AP TABLE")
def getPrompt(device): myDevice = Device.getDeviceObject(device) try: myDevice.getPrompt() except: myDevice.transmit("\r") myDevice.getPrompt()
def connect_client_to_ap(self, device, SSID=None): myDevice = Device.getDeviceObject(device) try: myDevice.connect_client_to_ap(SSID=SSID) except: myDevice.connect() myDevice.connect_client_to_ap(SSID=SSID)
def assert_network_in_ap(self, ap, nw): myDevice = Device.getDeviceObject(ap) myDevice.receive("#") myDevice.transmit("show network") output = myDevice.receive("#") log.info(output) if not nw in output: raise AssertionError("%s is not present in the network" % nw)
def connect_client_to_ap(device, SSID=None): myDevice = Device.getDeviceObject(device) try: myDevice.connect_client_to_ap(SSID=SSID) except: myDevice.connect() time.sleep(5) myDevice.connect_client_to_ap(SSID=SSID)
def verify_clients_table(self, client): myDevice = Device.getDeviceObject(client) #import pdb #pdb.set_trace() table = self.access_points_detail_client_table ip = myDevice.get("ip") mac = myDevice.get("mac") if myDevice.get("os") == "Win8": #os = "Windows" os = "Unknown" else: os = "Windows" mac_list = table.find_elements_by_xpath( "//span[contains(@id, 'clientsInterfaceTable_macaddr_display')]") #ip_list = table.find_elements_by_xpath("//span[contains(@id, 'clientsInterfaceTable_ipaddress_display')]") #log.info(ip_list) i = 0 try: #for ip_obj in ip_list: for mac_obj in mac_list: #if ip_obj.text == ip: if mac_obj.text == mac: index = i break i = i + 1 log.info("#" * 100) log.info(index) except: raise AssertionError("The client requested is not in the table") if not table.find_elements_by_xpath( "//span[contains(@id, 'clientsInterfaceTable_username_display')]" )[index].text == "Admin": raise AssertionError("Client Name doesnt match") if not table.find_elements_by_xpath( "//span[contains(@id, 'clientsInterfaceTable_ipaddress_display')]" )[index].text == ip: #if not table.find_elements_by_xpath("//span[contains(@id, 'clientsInterfaceTable_macaddr_display')]")[index].text == mac: raise AssertionError("Client IP doesnt match") if not table.find_elements_by_xpath( "//span[contains(@id, 'clientsInterfaceTable_devicetype_display')]" )[index].text == os: raise AssertionError("Client OS doesnt match") if not table.find_elements_by_xpath( "//span[contains(@id, 'clientsInterfaceTable_ssid_display')]" )[index].text == "TEST_Monitoring": raise AssertionError("Client NETWORK doesnt match") if not table.find_elements_by_xpath( "//span[contains(@id, 'clientsInterfaceTable_channel_display')]" )[index].text: raise AssertionError("Client CHANNEL doesnt match") if not table.find_elements_by_xpath( "//span[contains(@id, 'clientsInterfaceTable_connection_display')]" )[index].text == "802.11AN": raise AssertionError("Client TYPE doesnt match") if not table.find_elements_by_xpath( "//span[contains(@id, 'clientsInterfaceTable_role_display')]" )[index].text == "TEST_Monitoring": raise AssertionError("Client ROLE doesnt match")
def get_stats_from_ap(self, device): import re myDevice = Device.getDeviceObject(device) output = myDevice.get_running_config("GET_IDS_CONFIG") time.sleep(20) log.info(output) stat_dict = dict() stat_dict["Rogue"] = len(re.findall('Rogue',output, re.I)) stat_dict["Interfering"] = len(re.findall('Interfering', output, re.I)) return stat_dict
def get_stats_from_ap(self, device): import re myDevice = Device.getDeviceObject(device) output = myDevice.get_running_config("GET_IDS_CONFIG") time.sleep(20) log.info(output) stat_dict = dict() stat_dict["Rogue"] = len(re.findall('Rogue', output, re.I)) stat_dict["Interfering"] = len(re.findall('Interfering', output, re.I)) return stat_dict
def assert_client_present_in_ap(self, client): myDevice = Device.getDeviceObject(client) table = self.access_points_details_client_table ip = myDevice.get("ip") ip_list = table.find_elements_by_xpath("//span[contains(@id, 'clientsInterfaceTable_ipaddress_display')]") try: index = ip_list.index(ip) except: raise AssertionError("The client requested is not in the table")
def assert_client_present_in_ap(self, client): myDevice = Device.getDeviceObject(client) table = self.access_points_details_client_table ip = myDevice.get("ip") ip_list = table.find_elements_by_xpath( "//span[contains(@id, 'clientsInterfaceTable_ipaddress_display')]") try: index = ip_list.index(ip) except: raise AssertionError("The client requested is not in the table")
def connect_device_to_server(self, device): myDevice = Device.getDeviceObject(device) myDevice.connect_device_to_server() i = 1 while i < 10: if myDevice.get_device_status(): break else: time.sleep(5) i = i+1 if not myDevice.get_device_status(): raise AssertionError("Device is not attached to Athena Yet")
def reconnect(device): myDevice = Device.getDeviceObject(device) myDevice.reconnect() myDevice.setUsername("admin") myDevice.setPassword("test123") for i in range(0, 10): myDevice.transmit("show version") if "User" in myDevice.receive("User:"): break else: time.sleep(50) myDevice.getPrompt()
def connect_device_to_server(self, device): myDevice = Device.getDeviceObject(device) myDevice.connect_device_to_server() i = 1 while i < 10: if myDevice.get_device_status(): break else: time.sleep(5) i = i + 1 if not myDevice.get_device_status(): raise AssertionError("Device is not attached to Athena Yet")
def assert_ap_event_log(self, ap_list): if not isinstance(ap_list, list): ap_list = ap_list.split(" ") ap_mac_list = [] for ap in ap_list: ap_mac_list.append(Device.getDeviceObject(ap).get("mac")) table = self.event_log_table mac_list = table.find_elements_by_xpath("//span[contains(@id, 'EVENT_LOG_TABLE_mac_addr_display')]") for mac in mac_list: log.info(mac.text) if mac.text not in ap_mac_list and mac.text != "": raise AssertionError("Mac address that are not part of AP List is present")
def delete_switch_device_based_on_ip(self, device): myDevice = Device.getDeviceObject(device) switch_ip = myDevice.get("ip") if self.browser._browser.find_element_by_xpath( "//span[contains(.,'%s')]/../following-sibling::td[5]/a" % switch_ip): self.browser._browser.find_element_by_xpath( "//span[contains(.,'%s')]/../following-sibling::td[5]/a" % switch_ip).click() if self.confirm_delete_switch_ok_button: self.confirm_delete_switch_ok_button.click() time.sleep(15)
def assert_network_not_in_ap(self, ap, nw): myDevice = Device.getDeviceObject(ap) for i in range(0, 10): myDevice.receive("#") myDevice.transmit("show network") output = myDevice.receive("#") log.info(output) if not nw in output: break time.sleep(5) if nw in output: raise AssertionError("Network still exists in the configuration")
def delete_switch_device_based_on_ip(self, device): myDevice = Device.getDeviceObject(device) switch_ip = myDevice.get("ip") if self.browser._browser.find_element_by_xpath( "//span[contains(.,'%s')]/../following-sibling::td[5]/a" % switch_ip ): self.browser._browser.find_element_by_xpath( "//span[contains(.,'%s')]/../following-sibling::td[5]/a" % switch_ip ).click() if self.confirm_delete_switch_ok_button: self.confirm_delete_switch_ok_button.click() time.sleep(15)
def assert_backend(device, command=None, expected=None): """ Device : IAP or switch to used for backend validation. command : cli command expected : expected result in cli o/partition """ myDevice = Device.getDeviceObject(ap) # version = firmware_version.split('_')[0] myDevice.receive("#") myDevice.transmit("%s" % command) output = myDevice.receive("#") if not expected in output: raise AssertionError("%s not found in config." % expected)
def assert_backend(device, command=None, expected=None): ''' Device : IAP or switch to used for backend validation. command : cli command expected : expected result in cli o/partition ''' myDevice = Device.getDeviceObject(ap) # version = firmware_version.split('_')[0] myDevice.receive("#") myDevice.transmit("%s" % command) output = myDevice.receive("#") if not expected in output: raise AssertionError("%s not found in config." % expected)
def assert_running_config_include_deny(self,ap,denyconfig='',exists=False): myDevice = Device.getDeviceObject(ap) myDevice.receive("#") time.sleep(8) myDevice.transmit("sh ru | inc deny") time.sleep(8) output = myDevice.receive("#") if not exists: if denyconfig in output: raise AssertionError("%s is pushed to %s" %(denyconfig,ap)) else: if not denyconfig in output: raise AssertionError("%s is not pushed to %s" %(denyconfig,ap))
def assert_ap_event_log(self, ap_list): if not isinstance(ap_list, list): ap_list = ap_list.split(" ") ap_mac_list = [] for ap in ap_list: ap_mac_list.append(Device.getDeviceObject(ap).get("mac")) table = self.event_log_table mac_list = table.find_elements_by_xpath( "//span[contains(@id, 'EVENT_LOG_TABLE_mac_addr_display')]") for mac in mac_list: log.info(mac.text) if mac.text not in ap_mac_list and mac.text != "": raise AssertionError( "Mac address that are not part of AP List is present")
def unassign_switch_license(self,switch): self.clicking_switch_tab() self.click_on_search_icon() myDevice = Device.getDeviceObject(switch) serial = myDevice.get("serial") mac_address = myDevice.get("mac") self.mac_search_field.set(mac_address) self.click_on_search_button() self.browser._browser.find_element_by_xpath("//span[contains(.,'%s')]/../preceding-sibling::td[1]/input" %serial).click() try: if self.unassign_button : self.unassign_button.click() except: pass
def assert_latest_alert(self, ap, action): myDevice = Device.getDeviceObject(ap) mac = myDevice.get("mac") for i in range(0, 5): #table = self.access_points_alert_table #alert = table.find_element_by_id("alertsTable_select_row_0").text alert = self.first_alert.text if alert == "Access point %s is %s" % (mac, action): break time.sleep(50) #self.browser.refresh() if not alert == "Access point %s is %s" % (mac, action): log.error("Expected alert is not seen : %s" % alert) raise AssertionError("Expected alert is not seen")
def assert_firmware_version(self, ap, firmware_version): logger.debug("FirmwarePage : creating object of Device") myDevice = Device.getDeviceObject(ap) logger.debug("FirmwarePage : splitting the firmware version") version = firmware_version.split('_')[0] logger.debug("FirmwarePage : waiting to receive prompt") myDevice.receive("#") logger.debug("FirmwarePage : passing command 'show version' ") myDevice.transmit("show version") logger.debug("FirmwarePage : waiting to receive prompt") output = myDevice.receive("#") if not version in output: raise AssertionError( "%s Device is not upgraded to firmware version" % version)
def assert_latest_alert(self, ap, action): myDevice = Device.getDeviceObject(ap) mac = myDevice.get("mac") for i in range(0, 5): #table = self.access_points_alert_table #alert = table.find_element_by_id("alertsTable_select_row_0").text alert = self.first_alert.text if alert == "Access point %s is %s" % (mac, action): break time.sleep(50) #self.browser.refresh() if not alert == "Access point %s is %s" %(mac, action): log.error("Expected alert is not seen : %s" %alert) raise AssertionError("Expected alert is not seen")
def go_to_ap_page(self, ap): myDevice = Device.getDeviceObject(ap) try: ap_tag = self.browser._browser.find_element_by_xpath( "//td[@config='apsTable' and @title='%s']//span[contains(@id,'apsTable_name_display')]" % myDevice.get("mac")) ap_tag.click() #import pdb #pdb.set_trace() self.assert_ap_page(myDevice.get("mac")) return MonitoringAPDetailsPage(self.test, self.browser, self.config) except: log.error("Issue while moving into AP page")
def asserts_IAP1_details_in_firmware_vc_table(self, IAP): myDevice = Device.getDeviceObject(IAP) vc_name = myDevice.get("vc_name") location = myDevice.get("location") firmware_version = myDevice.get("firmware_version") if not self.browser._browser.find_element_by_xpath( "//td[@title='%s']" % vc_name): raise AssertionError('vc name is not displayed') if not self.browser._browser.find_element_by_xpath( "//td[@title='%s']/following-sibling::td[2]/span[2][@title='%s']" % (vc_name, location)): raise AssertionError('vc location is not displayed') if not self.browser._browser.find_element_by_xpath( "//td[@title='%s']/following-sibling::td[3][@title='%s']" % (vc_name, firmware_version)): raise AssertionError('firmware version is not displayed')
def assert_running_config_include_deny(self, ap, denyconfig='', exists=False): myDevice = Device.getDeviceObject(ap) myDevice.receive("#") time.sleep(8) myDevice.transmit("sh ru | inc deny") time.sleep(8) output = myDevice.receive("#") if not exists: if denyconfig in output: raise AssertionError("%s is pushed to %s" % (denyconfig, ap)) else: if not denyconfig in output: raise AssertionError("%s is not pushed to %s" % (denyconfig, ap))
def test_ath_11046_check_non_default_values_vc_name(self): myDevice = Device.getDeviceObject("IAP_1") vlan_id = myDevice.get("vlan") conf = self.config.config_vars system_page = self.LeftPanel.go_to_system_page() system_page.set_new_vc_name("IAP_1", conf.vc_name) system_page.set_new_vc_ip("IAP_1", conf.ip_add) system_page.check_non_default_values_vc_name_2() system_page._save_settings() system_page.assert_system_page_vc_field_values("IAP_1", "sh ru | inc name", conf.vc_name) system_page.assert_system_page_vc_field_values("IAP_1", "sh ru | inc virtual", conf.ip_add) system_page.assert_system_page_vc_field_values("IAP_1", "sh ru | inc time", "Pacific-Time -07") system_page.assert_system_page_vc_field_values("IAP_1", "sh ru | inc ntp", conf.ntp_server) system_page.assert_system_page_vc_field_values("IAP_1", "sh ru | inc band", "2.4ghz") system_page.assert_system_page_vc_field_values("IAP_1", "sh ru | inc vlan", vlan_id) system_page.assert_system_page_vc_field_values( "IAP_1", "sh ru | inc cpu", "dynamic-cpu-mgmt disable") time.sleep(10) DeviceLibrary.factoryReset("IAP_1") time.sleep(10) DeviceLibrary.getPrompt("IAP_1") DeviceLibrary.reconnect("IAP_1") time.sleep(90) inner_left_panel = self.TopPanel.click_slider_icon() inner_left_panel.click_expand_default_group_icon() inner_left_panel.select_vc("IAP_1") inner_left_panel.select_country_code( self.config.config_vars.country_india) # system_page.setting_original_vc_name("IAP_1",conf.vc_name) # system_page.setting_original_vc_ip("IAP_1",conf.ip_add) system_page.setting_default_values_2() system_page._save_settings()
def connect_device_to_server(device): myDevice = Device.getDeviceObject(device) try: myDevice.connect_device_to_server() except: myDevice.disconnect() time.sleep(100) myDevice.connect() myDevice.connect_device_to_server() i = 1 while i < 5: if myDevice.get_device_status(strict=True): break else: time.sleep(10) i = i + 1 if not myDevice.get_device_status(): raise AssertionError("Device is not attached to Athena Yet")
def move_unprovisioned_device(self,device,group=None,group_name=''): ''' Moves a unprovioned switch or IAP to new group or overwrite config to existing group. ''' myDevice = Device.getDeviceObject(device) if "IAP" in device: device_name=myDevice.get("vc_name") else: device_name=myDevice.get("switch_name") # self.TopPanel.click_slider_icon() # self.slider_icon.click() logger.debug("ManageGroupPage: Select device ") raw_input('check1') print self.browser._browser.find_element_by_xpath("//span[contains(.,'%s')]" %device_name) self.browser._browser.find_element_by_xpath("//span[contains(.,'%s')]" %device_name).click() import time time.sleep(5) # self.browser._browser.find_element_by_xpath("//span[contains(.,'%s')]" %device_name) self.browser._browser.find_element_by_xpath("//span[contains(.,'%s')]" %device_name).click() # self.browser._browser.find_element_by_xpath("//span[contains(.,'ArubaS2500')]").click() # self.browser._browser.find_element_by_xpath("//span[contains(.,'ArubaS2500')]").click() time.sleep(10) if group == 'New Group': logger.debug("ManageGroupPage: Click on new group.") self.unprovisioned_new_group.click() logger.debug("ManageGroupPage: set group name.") self.group_name.set(group_name) logger.debug("ManageGroupPage: Click on save") self.creategroup_btn.click() logger.debug("ManageGroupPage: set password.") self.password_text.set('test123') logger.debug("ManageGroupPage: set password again.") self.confirm_password_text.set('test123') logger.debug("ManageGroupPage: Click on save.") self.browser._browser.find_element_by_xpath("//button[contains(@id,'group_sidebar_cddc_creategrpddc') and text()='Save']").click() else: logger.debug("ManageGroupPage: Click on existing group") self.existing_group.click() logger.debug("ManageGroupPage: select group") self.browser._browser.find_element_by_xpath("//span[contains(@id,'group_table_name') and text()='%s']" %group_name).click() # print self.browser._browser.find_element_by_xpath("//span[contains(@id,'group_sidebar_save') and text()='Save']") # raw_input('save') logger.debug("ManageGroupPage: Click save") self.browser._browser.find_element_by_xpath("//span[contains(@id,'group_sidebar_save') and text()='Save']").click()
def disconnect_device_from_server(device): myDevice = Device.getDeviceObject(device) try: myDevice.connect_device_to_server("1.1.1.1") except: myDevice.disconnect() time.sleep(100) myDevice.connect() myDevice.connect_device_to_server("1.1.1.1") time.sleep(10) i = 1 while i < 10: if not myDevice.get_device_status(): break else: time.sleep(5) i = i + 1 if myDevice.get_device_status(): raise AssertionError("Device is attached to Athena Yet")
def verify_clients_table(self, client): myDevice = Device.getDeviceObject(client) #import pdb #pdb.set_trace() table = self.access_points_detail_client_table ip = myDevice.get("ip") mac = myDevice.get("mac") if myDevice.get("os") == "Win8": #os = "Windows" os = "Unknown" else: os = "Windows" mac_list = table.find_elements_by_xpath("//span[contains(@id, 'clientsInterfaceTable_macaddr_display')]") #ip_list = table.find_elements_by_xpath("//span[contains(@id, 'clientsInterfaceTable_ipaddress_display')]") #log.info(ip_list) i = 0 try: #for ip_obj in ip_list: for mac_obj in mac_list: #if ip_obj.text == ip: if mac_obj.text == mac: index = i break i = i + 1 log.info("#" * 100) log.info(index) except: raise AssertionError("The client requested is not in the table") if not table.find_elements_by_xpath("//span[contains(@id, 'clientsInterfaceTable_username_display')]")[index].text == "Admin": raise AssertionError("Client Name doesnt match") if not table.find_elements_by_xpath("//span[contains(@id, 'clientsInterfaceTable_ipaddress_display')]")[index].text == ip: #if not table.find_elements_by_xpath("//span[contains(@id, 'clientsInterfaceTable_macaddr_display')]")[index].text == mac: raise AssertionError("Client IP doesnt match") if not table.find_elements_by_xpath("//span[contains(@id, 'clientsInterfaceTable_devicetype_display')]")[index].text == os: raise AssertionError("Client OS doesnt match") if not table.find_elements_by_xpath("//span[contains(@id, 'clientsInterfaceTable_ssid_display')]")[index].text == "TEST_Monitoring": raise AssertionError("Client NETWORK doesnt match") if not table.find_elements_by_xpath("//span[contains(@id, 'clientsInterfaceTable_channel_display')]")[index].text: raise AssertionError("Client CHANNEL doesnt match") if not table.find_elements_by_xpath("//span[contains(@id, 'clientsInterfaceTable_connection_display')]")[index].text == "802.11AN": raise AssertionError("Client TYPE doesnt match") if not table.find_elements_by_xpath("//span[contains(@id, 'clientsInterfaceTable_role_display')]")[index].text == "TEST_Monitoring": raise AssertionError("Client ROLE doesnt match")
def assert_backend(device,command=None,expected=None): ''' Device : IAP or switch to used for backend validation. command : cli command expected : expected result in cli o/partition ''' myDevice = Device.getDeviceObject(device) if "IAP" in device: myDevice.receive("#") myDevice.transmit("%s"%command) output = myDevice.receive("#") if not expected in output: raise AssertionError("%s not found in config." %expected) else: myDevice.receive("\) #") myDevice.transmit("%s"%command) output = myDevice.receive("\) #") if not expected in output: raise AssertionError("%s not found in config." %expected)
def assert_device_in_group(self,device,group=''): ''' Verify if device is there in group or provisioned group ''' myDevice = Device.getDeviceObject(device) if "IAP" in device: device_name=myDevice.get("vc_name") else: device_name=myDevice.get("switch_name") if 'IAP' in device: logger.debug('InnerLeftPanel: Search IAP in group ') if not group == 'Unprovisioned': try: logger.debug('InnerLeftPanel:Click on + button ') print self.browser._browser.find_element_by_xpath("//span[contains(.,'%s')]/../preceding-sibling::span[contains(@id,'show_swarms')]"%group) self.browser._browser.find_element_by_xpath("//span[contains(.,'%s')]/../preceding-sibling::span[contains(@id,'show_swarms')]"%group).click() except: pass if not self.browser._browser.find_element_by_xpath("//span[@id='group_sidebar_groupname' and contains(.,'%s')]/../../following-sibling::ul[*]/li/a/span[contains(.,'%s')]" %(group,device_name)): raise AssertionError("InnerLeftPanel: Device %s is not present in %s"%(device_name,group)) else: logger.debug('InnerLeftPanel: Search device in unprovisioned group ') if not self.browser._browser.find_element_by_xpath("//span[contains(.,'Unprovisioned ')]/../following-sibling::ul[2]/li/a//span/span[contains(.,'%s')]" %device_name): raise AssertionError("InnerLeftPanel: Device %s is not present in unprovisioned group"%device_name) else: logger.debug('InnerLeftPanel:Search switch in group ') if not group == 'Unprovisioned': try: logger.debug('InnerLeftPanel:Click on + button ') self.browser._browser.find_element_by_xpath("//span[contains(.,'%s')]/../preceding-sibling::span[contains(@id,'show_swarms')]"%group).click() except: pass if not self.browser._browser.find_element_by_xpath("//span[@id='group_sidebar_groupname' and contains(.,'%s')]/../../following-sibling::ul[*]/li/a/span[contains(.,'%s')]" %(group,device_name)): raise AssertionError("InnerLeftPanel: Device %s is not present in %s"%(device_name,group)) else: logger.debug('InnerLeftPanel: Search switch in unprovisioned group ') if not self.browser._browser.find_element_by_xpath("//span[contains(.,'Unprovisioned')]/../following-sibling::ul[2]/li/a//span/span[contains(.,'%s')]" %device_name): raise AssertionError("InnerLeftPanel: Device %s is not present in unprovisioned group"%device_name)
def go_to_client_details_page(self, client): import pdb #pdb.set_trace() myDevice = Device.getDeviceObject(client) table = self.client_monitoring_table entries = table.find_elements_by_xpath("//span[contains(@id,'clientsTable_macaddr_display_')]") for entry in entries: if entry.text == myDevice.get("mac"): entry.click() time.sleep(5) for i in range(1, 5): try: log.info("Checking Client Label in Clients Detail Page : %s" %self.client_details_page_label.text) if self.client_details_page_label.text == myDevice.get("mac"): break else: time.sleep(5) self.browser.refresh() except: time.sleep(5) self.browser.refresh() if not self.client_details_page_label.text == myDevice.get("mac"): raise AssertionError("NOT IN THE EXPECTED CLIENT PAGE")
def move_vc_to_group(self, group, vc): myDevice = Device.getDeviceObject(vc) mac = myDevice.get("mac") vc_name = mac.split(":") vc_name = "instant-%s:%s:%s" %(vc_name[-3].upper(), vc_name[-2].upper(), vc_name[-1].upper()) logger.debug("ManageGroupPage: Clicking on 'All Group' group ") self.all_group.click() time.sleep(5) if self.select_all.is_selected(): self.select_all.click() logger.debug("ManageGroupPage: Clicking on vc checkbox ") vc_list = self.browser._browser.find_elements_by_xpath("//table[@id='manageGroupSwarms']//tr//*[contains(@id, 'manageVCListTable_name_display')]") for vc in vc_list: if vc.text == vc_name: #vc.click() index = vc_list.index(vc) sel_list = self.browser._browser.find_elements_by_xpath("//table[@id='manageGroupSwarms']//tr//*[contains(@id, 'manageVCListTable_row_selector')]//input") sel_list[index].click() #tr = vc.find_element_by_xpath("..") #tr.find_element_by_xpath("//td[contains(@id, 'manageVCListTable_row_selector')]//input").click() #table = self.browser._browser.find_element_by_xpath("//table[@id='manageGroupSwarms']") #for tr in table.find_elements_by_tag_name("tr"): # if tr.find_element_by_xpath("//*[contains(@id, 'manageVCListTable_name_display')]").text == vc_name: # tr.find_element_by_xpath("//*[contains(@id, 'manageVCListTable_row_selector')]//input").click() #self.virtual_controller.click() logger.debug("ManageGroupPage: Clicking on 'Move' button ") self.move.click() self.buy_time() logger.debug("ManageGroupPage: Clicking on required 'group' ") group_obj = self.browser._browser.find_element_by_xpath("//span[contains(@id,'group_table_name') and contains(text(), '%s')]" % group) logger.info(group_obj) group_obj.click() logger.debug("ManageGroupPage: Clicking on 'Save' button ") self.save.click() if not self.virtual_controller: self.logo.click() time.sleep(6)
def assert_client_type(self, client): myDevice = Device.getDeviceObject(client) if not self.client_device_type == myDevice.get("os"): #raise AssertionError("Client Type does not match") log.error("Clent Type Does Not Match")
def select_particular_vc(self, iap): myDevice = Device.getDeviceObject(iap) ip = myDevice.get("ip") self.browser._browser.find_element_by_xpath("//td[@title='%s']/following-sibling::td[6]" % ip).click()
def select_particular_iap_type(self, iap): myDevice = Device.getDeviceObject(iap) aptype = myDevice.get("ap_type") self.browser._browser.find_element_by_xpath("//td[@title='%s']/following-sibling::td[3]" % aptype).click()