def __init__(self, enDeviceVersion): ''' Constructor ''' CDevice.__init__(self) CDevice.SetDeviceType(self, CDeviceType.H3C_ER3200G2) CDevice.SetDeviceVersion(self, enDeviceVersion)
def ConfigureAPTemplate(self, szTemplateName, enApTemplateType, szSSID): if CDevice.GetDeviceType( self) == CDeviceType.H3C_ER3200G2 and CDevice.GetDeviceVersion( self) == CDeviceVersion.H3C_ERHMG2_MNW100_R1118: #CDevice.OpenURL(self, self.GetURL() + const.EXTEND_URL_ADD_AP_TEMPLATE); #self.GetBrowser().find_element_by_name("op_new").click(); CDevice.OpenURL( self, self.GetURL() + const.EXTEND_URL_ADD_AP_TEMPLATE_LIST) self.GetBrowser().find_element_by_name("template_name").send_keys( szTemplateName) self.GetBrowser().find_element_by_partial_link_text( "2.4G").click() if enApTemplateType == CAPTemplateType.AP_TEMPLATE_1_149: self.GetBrowser().find_element_by_name( "template_describe").send_keys("1-149") Select(self.GetBrowser().find_element_by_name( "swlanMode")).select_by_index(4) Select(self.GetBrowser().find_element_by_name( "swlanWidth")).select_by_index(1) Select(self.GetBrowser().find_element_by_name( "wlanChannel")).select_by_index(1) self.GetBrowser().find_element_by_id("amend").click() #elif enApTemplateType == CAPTemplateType.AP_TEMPLATE_6_153: #elif enApTemplateType == CAPTemplateType.AP_TEMPLATE_11_157: time.sleep(1)
def LoginInputUsernamePassword(self): if CDevice.GetDeviceType( self) == CDeviceType.H3C_ER3200G2 and CDevice.GetDeviceVersion( self) == CDeviceVersion.H3C_ERHMG2_MNW100_R1118: self.GetBrowser().find_element_by_name( const.NAME_ACCOUNT).send_keys(self.GetUsername()) self.GetBrowser().find_element_by_name( const.NAME_PASSWORD).send_keys(self.GetPassword())
def ConnectToInternet_StaticLine(self): if CDevice.GetDeviceType( self) == CDeviceType.H3C_ER3200G2 and CDevice.GetDeviceVersion( self) == CDeviceVersion.H3C_ERHMG2_MNW100_R1118: CDevice.OpenURL(self, self.GetURL() + const.EXTEND_URL_WAN_NEW) Select(self.GetBrowser().find_element_by_name( "wan1IPMode")).select_by_index(0) self.GetBrowser().find_element_by_name("WAN1_IP").clear() self.GetBrowser().find_element_by_name("WAN1_IP").send_keys( CDevice.GetStaticLineIP(self)) elementNetMask = self.GetBrowser().find_element_by_name("WAN1_NM") elementNetMask.clear() elementNetMask.send_keys(Keys.BACKSPACE) elementNetMask.send_keys(Keys.BACKSPACE) elementNetMask.send_keys(Keys.BACKSPACE) elementNetMask.send_keys(Keys.BACKSPACE) elementNetMask.send_keys(Keys.BACKSPACE) elementNetMask.send_keys(Keys.BACKSPACE) elementNetMask.send_keys(Keys.BACKSPACE) elementNetMask.send_keys(Keys.BACKSPACE) elementNetMask.send_keys((CDevice.GetStaticLineMask(self))[1:]) self.GetBrowser().find_element_by_name("WAN1_GW").clear() self.GetBrowser().find_element_by_name("WAN1_GW").send_keys( CDevice.GetStaticLineGateway(self)) self.GetBrowser().find_element_by_name("WAN1_DS1").clear() self.GetBrowser().find_element_by_name("WAN1_DS1").send_keys( CDevice.GetStaticLineDNS1(self)) self.GetBrowser().find_element_by_name("WAN1_DS2").clear() self.GetBrowser().find_element_by_name("WAN1_DS2").send_keys( CDevice.GetStaticLineDNS2(self)) self.GetBrowser().find_element_by_xpath( "//input[@value='应用'][@type='button']").click() CDevice.CloseTab(self)
def ConfigureSSIDAdvance(self): if CDevice.GetDeviceType( self) == CDeviceType.H3C_ER3200G2 and CDevice.GetDeviceVersion( self) == CDeviceVersion.H3C_ERHMG2_MNW100_R1118: CDevice.OpenURL(self, self.GetURL() + const.EXTEND_URL_AP_SSID_ADVANCE) if self.GetBrowser().find_element_by_name( "wlanRoaming").is_selected(): pass else: self.GetBrowser().find_element_by_name("wlanRoaming").click() self.GetBrowser().find_element_by_name("amend").click() time.sleep(1)
def EnableAPMngIP(self, bIsEnabled): if CDevice.GetDeviceType( self) == CDeviceType.H3C_ER3200G2 and CDevice.GetDeviceVersion( self) == CDeviceVersion.H3C_ERHMG2_MNW100_R1118: CDevice.OpenURL(self, self.GetURL() + const.EXTEND_URL_ENABLE_AP_MNG_IP) if bIsEnabled == True: Select(self.GetBrowser().find_element_by_name( "manage_set")).select_by_index(1) elif bIsEnabled == False: Select(self.GetBrowser().find_element_by_name( "manage_set")).select_by_index(0) self.GetBrowser().find_element_by_id("amend").click() time.sleep(1)
def AddVlanToTrunk(self, nIndex): if CDevice.GetDeviceType( self) == CDeviceType.H3C_ER3200G2 and CDevice.GetDeviceVersion( self) == CDeviceVersion.H3C_ERHMG2_MNW100_R1118: CDevice.OpenURL(self, self.GetURL() + const.EXTEND_URL_VLAN_PORT_SET) frameConfigureVlanPort = self.GetBrowser( ).find_element_by_tag_name("iframe") self.GetBrowser().switch_to_frame(frameConfigureVlanPort) #portLanSWElement = self.GetBrowser().find_elements_by_link_text("LAN1"); #ActionChains(self.GetBrowser()).double_click(portLanSWElement).perform(); #self.GetBrowser().find_element_by_xpath("//IMG["+ str(nIndex) + "]").click(); self.GetBrowser().find_element_by_xpath( "//table[@id='disableclick']/tbody/tr[" + str(nIndex + 1) + "]/td[1]").click()
def ConnectToInternet_PPPoE(self): if CDevice.GetDeviceType( self) == CDeviceType.H3C_ER3200G2 and CDevice.GetDeviceVersion( self) == CDeviceVersion.H3C_ERHMG2_MNW100_R1118: CDevice.OpenURL(self, self.GetURL() + const.EXTEND_URL_WAN_NEW) Select(self.GetBrowser().find_element_by_name( "wan1IPMode")).select_by_index(2) self.GetBrowser().find_element_by_name("WAN1_PUN").clear() self.GetBrowser().find_element_by_name("WAN1_PUN").send_keys( CDevice.GetPPPoEAccountName(self)) self.GetBrowser().find_element_by_name("WAN1_PPW").clear() self.GetBrowser().find_element_by_name("WAN1_PPW").send_keys( CDevice.GetPPPoEPassword(self)) self.GetBrowser().find_element_by_xpath( "//input[@value='应用'][@type='button']").click() time.sleep(1)
def AddVlanInterface(self, szVlanId, szInterfaceIp, szMask): if CDevice.GetDeviceType( self) == CDeviceType.H3C_ER3200G2 and CDevice.GetDeviceVersion( self) == CDeviceVersion.H3C_ERHMG2_MNW100_R1118: CDevice.OpenURL(self, self.GetURL() + const.EXTEND_URL_VLAN_ADD) self.GetBrowser().find_element_by_name("op_new").click() self.GetBrowser().find_element_by_name("vlan_id").clear() self.GetBrowser().find_element_by_name("vlan_id").send_keys( szVlanId) self.GetBrowser().find_element_by_name("IP").clear() self.GetBrowser().find_element_by_name("IP").send_keys( szInterfaceIp) self.GetBrowser().find_element_by_name("mask").clear() self.GetBrowser().find_element_by_name("mask").send_keys( Keys.BACKSPACE) self.GetBrowser().find_element_by_name("mask").send_keys( Keys.BACKSPACE) self.GetBrowser().find_element_by_name("mask").send_keys( Keys.BACKSPACE) self.GetBrowser().find_element_by_name("mask").send_keys( Keys.BACKSPACE) self.GetBrowser().find_element_by_name("mask").send_keys( Keys.BACKSPACE) self.GetBrowser().find_element_by_name("mask").send_keys( Keys.BACKSPACE) self.GetBrowser().find_element_by_name("mask").send_keys( Keys.BACKSPACE) self.GetBrowser().find_element_by_name("mask").send_keys( Keys.BACKSPACE) self.GetBrowser().find_element_by_name("mask").send_keys( Keys.BACKSPACE) self.GetBrowser().find_element_by_name("mask").send_keys( Keys.BACKSPACE) self.GetBrowser().find_element_by_name("mask").send_keys( Keys.BACKSPACE) self.GetBrowser().find_element_by_name("mask").send_keys( Keys.BACKSPACE) self.GetBrowser().find_element_by_name("mask").send_keys( szMask[1:]) self.GetBrowser().find_element_by_name("amend").click() time.sleep(3) CDevice.CloseTab(self)
def ConfigureAPMngIP(self, szAPMngIP, szAPMngMask, szAPStartIP, szAPEndIP): if CDevice.GetDeviceType( self) == CDeviceType.H3C_ER3200G2 and CDevice.GetDeviceVersion( self) == CDeviceVersion.H3C_ERHMG2_MNW100_R1118: CDevice.OpenURL(self, self.GetURL() + const.EXTEND_URL_CONFIG_AP_MNG_IP) self.GetBrowser().find_element_by_name("PrivIP").clear() self.GetBrowser().find_element_by_name("PrivIP").send_keys( szAPMngIP) self.GetBrowser().find_element_by_name("PrivMask").clear() self.GetBrowser().find_element_by_name("PrivMask").send_keys( szAPMngMask) self.GetBrowser().find_element_by_name("PrivPoolStart").clear() self.GetBrowser().find_element_by_name("PrivPoolStart").send_keys( szAPStartIP) self.GetBrowser().find_element_by_name("PrivPoolEnd").clear() self.GetBrowser().find_element_by_name("PrivPoolEnd").send_keys( szAPEndIP) self.GetBrowser().find_element_by_id("id_confirm").click() time.sleep(1)
def AddDHCPPoolToVlan(self, szVlanId, szDHCPPoolStartIp, szDHCPPoolEndIp, szDNS1, szDNS2): if CDevice.GetDeviceType( self) == CDeviceType.H3C_ER3200G2 and CDevice.GetDeviceVersion( self) == CDeviceVersion.H3C_ERHMG2_MNW100_R1118: CDevice.OpenURL(self, self.GetURL() + const.EXTEND_URL_DHCP_ADD_TO_VLAN) self.GetBrowser().find_element_by_name("op_new").click() selectorVLAN = self.GetBrowser().find_element_by_name("dhcpd_vlan") Select(selectorVLAN).select_by_value("VLAN" + szVlanId) self.GetBrowser().find_element_by_name("dhcp_en").click() self.GetBrowser().find_element_by_name("StartIP").send_keys( szDHCPPoolStartIp) self.GetBrowser().find_element_by_name("EndIP").send_keys( szDHCPPoolEndIp) self.GetBrowser().find_element_by_name("MainDNS").send_keys(szDNS1) self.GetBrowser().find_element_by_name("SecondDNS").send_keys( szDNS2) self.GetBrowser().find_element_by_name("amend").click() time.sleep(1)
def QosRateLimit(self, start_ip, end_ip, up_limit, down_limit): if CDevice.GetDeviceType( self) == CDeviceType.H3C_ER3200G2 and CDevice.GetDeviceVersion( self) == CDeviceVersion.H3C_ERHMG2_MNW100_R1118: CDevice.OpenURL(self, self.GetURL() + const.EXTEND_URL_RATE_LIMIT) attribute = self.GetBrowser().find_element_by_id( "ID_BOUND_EN_1").get_attribute("disabled") if attribute: self.GetBrowser().find_element_by_name( "ipqos_lanip_en").click() self.GetBrowser().find_element_by_id("ID_BOUND_EN_2").click() self.GetBrowser().find_element_by_name("applybtn").click() self.GetBrowser().find_element_by_name("op_new").click() self.GetBrowser().find_element_by_id("start_ip").send_keys( start_ip) self.GetBrowser().find_element_by_id("end_ip").send_keys(end_ip) self.GetBrowser().find_element_by_id("up_limit").send_keys( up_limit) self.GetBrowser().find_element_by_id("down_limit").send_keys( down_limit) self.GetBrowser().find_element_by_name("amend").click() time.sleep(1)
def AddVlanToTrunk(self, nIndex, szPVID, szAllowedVlan): if CDevice.GetDeviceType( self) == CDeviceType.H3C_ER3200G2 and CDevice.GetDeviceVersion( self) == CDeviceVersion.H3C_ERHMG2_MNW100_R1118: CDevice.OpenURL(self, self.GetURL() + const.EXTEND_URL_VLAN_PORT_SET) frameConfigureVlanPort = self.GetBrowser( ).find_element_by_tag_name("iframe") self.GetBrowser().switch_to_frame(frameConfigureVlanPort) #portLanSWElement = self.GetBrowser().find_elements_by_link_text("LAN1"); #ActionChains(self.GetBrowser()).double_click(portLanSWElement).perform(); #self.GetBrowser().find_element_by_xpath("//IMG["+ str(nIndex) + "]").click(); self.GetBrowser().find_element_by_xpath( "//table[@id='disableclick']/tbody/tr[" + str(nIndex + 1) + "]/td[1]").click() self.GetBrowser().switch_to_default_content() selectorPVID = self.GetBrowser().find_element_by_name("pvid_value") Select(selectorPVID).select_by_value(szPVID) self.GetBrowser().find_element_by_name("permit_vlan").send_keys( szAllowedVlan) #time.sleep(3) self.GetBrowser().find_element_by_name("permit_vlan").send_keys( Keys.TAB, Keys.ENTER) time.sleep(1)
def LoginSubmit(self): if CDevice.GetDeviceType( self) == CDeviceType.H3C_ER3200G2 and CDevice.GetDeviceVersion( self) == CDeviceVersion.H3C_ERHMG2_MNW100_R1118: self.GetBrowser().find_element_by_name( const.NAME_SUBMIT).send_keys(Keys.ENTER)
def ConfigureAPTemplate(self, szTemplateName, szTemplateDesc, enApTemplateType, szCustomerSSID1, szCustomerSSID2, szCustomerKey1, szCustomerKey2): if CDevice.GetDeviceType( self) == CDeviceType.H3C_ER3200G2 and CDevice.GetDeviceVersion( self) == CDeviceVersion.H3C_ERHMG2_MNW100_R1118: CDevice.OpenURL(self, self.GetURL() + const.EXTEND_URL_ADD_AP_TEMPLATE) self.GetBrowser().find_element_by_name("op_new").click() allhandles = self.GetBrowser().window_handles #获取当前窗口句柄 #print(allhandles); if self.GetBrowser().current_window_handle == allhandles[1]: pass else: self.GetBrowser().switch_to_window(allhandles[1]) #切换窗口 #CDevice.OpenURL(self, self.GetURL() + const.EXTEND_URL_ADD_AP_TEMPLATE_LIST); self.GetBrowser().find_element_by_name("template_name").send_keys( szTemplateName) self.GetBrowser().find_element_by_name( "template_describe").send_keys(szTemplateDesc) #self.GetBrowser().find_element_by_xpath("//tr[@id='Ssidbasicset']/td[1]").click(); Select(self.GetBrowser().find_element_by_name( "swlanMode")).select_by_index(4) Select(self.GetBrowser().find_element_by_name( "swlanWidth")).select_by_index(1) if enApTemplateType == CAPTemplateType.AP_TEMPLATE_1_149: Select(self.GetBrowser().find_element_by_name( "wlanChannel")).select_by_index(1) elif enApTemplateType == CAPTemplateType.AP_TEMPLATE_6_153: Select(self.GetBrowser().find_element_by_name( "wlanChannel")).select_by_index(6) elif enApTemplateType == CAPTemplateType.AP_TEMPLATE_11_157: Select(self.GetBrowser().find_element_by_name( "wlanChannel")).select_by_index(11) self.ConfigureExistSSID(szCustomerSSID1 + "-2.4G", szCustomerKey1, CFrequencePointType.FREQUENCE_POINT_2Dot4G) self.ConfigureNewSSID(szCustomerSSID1 + "Guest-2.4G", szCustomerKey2) self.GetBrowser().find_element_by_xpath( "//tr[@id='Ssidbasicset']/td[1]").click() time.sleep(1) self.GetBrowser().find_element_by_xpath( "//tr[@id='Ssidbasicset']/td[1]").click() time.sleep(1) self.GetBrowser().find_element_by_xpath( "//tr[@id='Ssidbasicset']/td[1]").click() self.GetBrowser().find_element_by_xpath( "//tr[@id='ssidtaile5G']/td[1]").click() Select(self.GetBrowser().find_element_by_name( "swlanMode_5g")).select_by_index(1) Select(self.GetBrowser().find_element_by_name( "swlanWidth_5g")).select_by_index(2) if enApTemplateType == CAPTemplateType.AP_TEMPLATE_1_149: Select(self.GetBrowser().find_element_by_name( "wlanChannel_5g")).select_by_index(9) elif enApTemplateType == CAPTemplateType.AP_TEMPLATE_6_153: Select(self.GetBrowser().find_element_by_name( "wlanChannel_5g")).select_by_index(10) elif enApTemplateType == CAPTemplateType.AP_TEMPLATE_11_157: Select(self.GetBrowser().find_element_by_name( "wlanChannel_5g")).select_by_index(11) self.ConfigureExistSSID(szCustomerSSID2 + "-5G", szCustomerKey1, CFrequencePointType.FREQUENCE_POINT_5G) self.ConfigureNewSSID(szCustomerSSID2 + "Guest-5G", szCustomerKey2) self.GetBrowser().find_element_by_xpath( "//tr[@id='ssidtaile5G']/td[1]").click() time.sleep(1) self.GetBrowser().find_element_by_xpath( "//tr[@id='ssidtaile5G']/td[1]").click() time.sleep(1) self.GetBrowser().find_element_by_xpath( "//tr[@id='ssidtaile5G']/td[1]").click() self.GetBrowser().find_element_by_id("amend").click() self.GetBrowser().switch_to_window(allhandles[0]) self.GetBrowser().switch_to_default_content() time.sleep(1)