from test_case import AC_001_ExpansionSwitch from test_case import AC_002_APmanagement from test_case import AC_003_netName from test_case import AC_004_Rftemplate from test_case import AC_005_loadBalancing from test_case import AC_006_APSoftware from test_case import AC_007_configlist from test_case import VPNconfig_001_ipsec from test_case import VPNconfig_002_PPTPL2TP from test_case import WIFIconfig_001_configGuide from test_case import WIFIconfig_002_BasicSet from test_case import WIFIconfig_003_RFConfig from test_case import SysMonitor_001_sysStatic from common.send_mail import sendMail CPUmodel = getCPUmodel() WanNum = getWanNum() #手动添加用例 suite = unittest.TestSuite() #1、性能参数 if True: print('1性能参数') #初始化交换机/恢复出厂路由器/清理windows进程 if testCount > 1: if ('SoftVersion%s' % testCount) not in getweb(ReplaceVersion): suite.addTest( sysConfig_006_softwareUpdata.softwareUpdate( 'test_newSoftware%s' % testCount)) suite.addTest(swconfig('test_initSwPort'))
def test_001_wirelessMode(self): u'''射频信息&&无线模式''' wificonfig = RFConfigPage(self.driver, self.url) if str(support2).isdigit(): #判断字符串是否为数字 logger.info('support:', support2) logger.info(u'参数支持2.4G无线') cpumodel = getCPUmodel() try: self.driver.implicitly_wait(2) wificonfig.click_wifiConfig() time.sleep(0.5) except AttributeError: CapPic(self.driver) logger.info(u'软件不支持无线配置,与参数表不符') raise Exception('软件不支持无线配置,与参数表不符') else: logger.info(u'软件支持无线配,与参数表相符') self.driver.implicitly_wait(10) wificonfig.click_RFConfig() time.sleep(1) #2.4G WrlessEn2 = wificonfig.getAttribute_byXpath( wificonfig.WrlessEn2s, 'checked') self.assertEqual(WrlessEn2, 'true', msg='2.4G默认未开启') mode_2 = wificonfig.selelement_byName(wificonfig.wrlessMode2) if cpumodel == 'MTK': Select(mode_2).select_by_value('6') #仅11n time.sleep(0.3) Select(mode_2).select_by_value('4') # 仅11g time.sleep(0.3) Select(mode_2).select_by_value('9') # 11b/g/n混合 time.sleep(0.3) elif cpumodel == 'Qualcomm': Select(mode_2).select_by_value('1') # 仅11n time.sleep(0.3) Select(mode_2).select_by_value('2') # 仅11g time.sleep(0.3) Select(mode_2).select_by_value('6') # 11b/g/n混合 time.sleep(0.3) channel_2 = wificonfig.selelement_byName(wificonfig.channel2) Select(channel_2).select_by_value('1') time.sleep(0.2) Select(channel_2).select_by_value('2') time.sleep(0.2) Select(channel_2).select_by_value('3') time.sleep(0.2) Select(channel_2).select_by_value('4') time.sleep(0.2) Select(channel_2).select_by_value('5') time.sleep(0.2) Select(channel_2).select_by_value('6') time.sleep(0.2) Select(channel_2).select_by_value('7') time.sleep(0.2) Select(channel_2).select_by_value('8') time.sleep(0.2) Select(channel_2).select_by_value('9') time.sleep(0.2) Select(channel_2).select_by_value('10') time.sleep(0.2) Select(channel_2).select_by_value('11') time.sleep(0.2) Select(channel_2).select_by_value('0') #自动 time.sleep(0.2) chanWidth_2 = wificonfig.selelement_byName(wificonfig.chanWidth2) if cpumodel == 'MTK': Select(chanWidth_2).select_by_value('1') #自动 time.sleep(0.2) Select(chanWidth_2).select_by_value('0') # 20M time.sleep(0.2) Select(chanWidth_2).select_by_value('2') # 40M time.sleep(0.2) elif cpumodel == 'Qualcomm': Select(chanWidth_2).select_by_value('0') # 自动 time.sleep(0.2) Select(chanWidth_2).select_by_value('1') # HT20 time.sleep(0.2) Select(chanWidth_2).select_by_value('2') # HT40- time.sleep(0.2) Select(chanWidth_2).select_by_value('3') # HT40 time.sleep(0.2) Select(chanWidth_2).select_by_value('4') # HT40+ time.sleep(0.2) wificonfig.click_gjxxa() time.sleep(0.5) wificonfig.input_beacon2('100') wificonfig.input_rts2('1') wificonfig.input_fragment2('256') wificonfig.input_dtim2('255') wificonfig.click_wmmC2() wificonfig.click_wmmEn2() wificonfig.click_shortC2() wificonfig.click_shortEn2() #5G if support5 != '--': try: self.driver.implicitly_wait(2) WrlessEn5 = wificonfig.getAttribute_byXpath( wificonfig.WrlessEn5s, 'checked') self.assertEqual(WrlessEn5, 'true', msg='5G默认未开启') except AttributeError: CapPic(self.driver) logger.info(u'软件不支持5G,与参数表不符') raise Exception('软件不支持5G,与参数表不符') else: logger.info(u'软件支持5G,与参数表相符') self.driver.implicitly_wait(10) WrlessEn5 = wificonfig.getAttribute_byXpath( wificonfig.WrlessEn5s, 'checked') self.assertEqual(WrlessEn5, 'true', msg='5G默认未开启') mode_5 = wificonfig.selelement_byName(wificonfig.wrlessMode5) if cpumodel == 'MTK': Select(mode_5).select_by_value('2') time.sleep(0.3) Select(mode_5).select_by_value('8') time.sleep(0.3) Select(mode_5).select_by_value('14') time.sleep(0.3) Select(mode_5).select_by_value('15') time.sleep(0.3) elif cpumodel == 'Qualcomm': Select(mode_5).select_by_value('1') #仅11n time.sleep(0.3) Select(mode_5).select_by_value('3') #仅11a time.sleep(0.3) Select(mode_5).select_by_value('4') #11a/n混合 time.sleep(0.3) Select(mode_5).select_by_value('5') #11ac time.sleep(0.3) channel_5 = wificonfig.selelement_byName(wificonfig.channel5) Select(channel_5).select_by_value('36') time.sleep(0.2) Select(channel_5).select_by_value('40') time.sleep(0.2) Select(channel_5).select_by_value('44') time.sleep(0.2) Select(channel_5).select_by_value('48') time.sleep(0.2) Select(channel_5).select_by_value('52') time.sleep(0.2) Select(channel_5).select_by_value('56') time.sleep(0.2) Select(channel_5).select_by_value('60') time.sleep(0.2) Select(channel_5).select_by_value('64') time.sleep(0.2) Select(channel_5).select_by_value('149') time.sleep(0.2) Select(channel_5).select_by_value('153') time.sleep(0.2) Select(channel_5).select_by_value('157') time.sleep(0.2) Select(channel_5).select_by_value('161') time.sleep(0.2) Select(channel_5).select_by_value('165') time.sleep(0.2) Select(channel_5).select_by_value('0') # 自动 time.sleep(0.2) chanWidth_5 = wificonfig.selelement_byName( wificonfig.chanWidth5) if cpumodel == 'MTK': Select(chanWidth_5).select_by_value('1') # 自动 time.sleep(0.2) Select(chanWidth_5).select_by_value('2') # 20M time.sleep(0.2) Select(chanWidth_5).select_by_value('0') # 40M time.sleep(0.2) vhtChanWidth_5 = wificonfig.selelement_byName( wificonfig.vhtChanWidth_5) time.sleep(0.3) Select(vhtChanWidth_5).select_by_value('1') # HT80 time.sleep(0.2) Select(vhtChanWidth_5).select_by_value('0') # 20/40 time.sleep(0.2) elif cpumodel == 'Qualcomm': Select(chanWidth_5).select_by_value('0') # 自动 time.sleep(0.2) Select(chanWidth_5).select_by_value('1') # HT20 time.sleep(0.2) Select(chanWidth_5).select_by_value('2') # HT40- time.sleep(0.2) Select(chanWidth_5).select_by_value('3') # HT40 time.sleep(0.2) Select(chanWidth_5).select_by_value('4') # HT40+ time.sleep(0.2) Select(chanWidth_5).select_by_value('5') # HT80 time.sleep(0.2) wificonfig.input_beacon5('100') wificonfig.input_rts5('1') wificonfig.input_fragment5('256') wificonfig.input_dtim5('255') wificonfig.click_wmmC5() wificonfig.click_wmmEn5() wificonfig.click_shortC5() wificonfig.click_shortEn5() elif support5 == '--': logger.info(u'参数不支持5G无线') try: self.driver.implicitly_wait(2) wificonfig.getAttribute_byXpath(wificonfig.WrlessEn5s, 'checked') except AttributeError: logger.info(u'软件不支持5G无线,与参数表相符') except NoSuchElementException: logger.info(u'软件不支持5G无线,与参数表相符') else: CapPic(self.driver) logger.info(u'软件支持5G无线,与参数表不符') raise Exception(u'软件支持5G无线,与参数表不符') else: logger.info(u'参数表读取异常') logger.info(u'参数表读取值为:', support5) raise Exception(u'参数表读取异常') else: logger.info(u'参数不支持2.4G无线') try: self.driver.implicitly_wait(2) wificonfig.click_wifiConfig() except AttributeError: logger.info(u'软件不支持2.4G无线,与参数表相符') else: CapPic(self.driver) logger.info(u'软件支持2.4G无线,与参数表不符') raise Exception(u'软件支持2.4G无线,与参数表不符') self.driver.quit() logger.info('test_001_wirelessMode passed')
def softwareReplac(version=getweb('ReplaceVersion1')): # ReplaceVersion1 = getweb('ReplaceVersion1') hostip = gettelnet('host') port = gettelnet('port') licenseSN = getweb('licenseSN') username = bytes(getweb('User'), encoding="utf8") password = bytes(getweb('Passwd'), encoding="utf8") pcaddr = socket.gethostbyname(socket.getfqdn(socket.gethostname())) CPUmodel = getCPUmodel() license = IFlicense(version) # print(license) # 打开tftp32.exe, # 注意:tftp32打开后的目录是由 由哪个脚本执行 所在的路径决定 # 直接运行该脚本,则tftp32的目录是‘test_003_udp69’所在的‘D:\python\SEWEB\3.1.1Router\test_case\Port_mapping’ # 由all_test.py或者ProductModel_test.py调用执行,则目录为‘D:\python\SEWEB\3.1.1Router\run’ # 因此 需把握好 对应目录中包含上传的文件,此脚本设定上传的文件为'tftpd32.exe' handle = win32process.CreateProcess( r"D:\python\SEWEB\3.1.1Router\test_case\tftpd32.exe", '', None, None, 0, win32process.CREATE_NO_WINDOW, None, None, win32process.STARTUPINFO()) # 打开tftp32.exe,获得其句柄 time.sleep(2) if CPUmodel == 'X86': if '.img' not in version: raise Exception(u'X86设备需要 img文件') elif '.bin' not in version: version = version + '.bin' VersionCmd = bytes(('tftp -gr ' + version + ' ' + pcaddr + ' 69'), encoding='utf8') tn = telnetlib.Telnet(host=hostip, port=port, timeout=10) tn.set_debuglevel(5) # 级别越高输出的调试信息越多,并没有看出区别 tn.read_until(b'login:'******'Password:'******'#') tn.write(VersionCmd + b'\n') tn.read_until(b'#') if CPUmodel == 'MTK' or CPUmodel == 'Qualcomm': mtdwriteCmd = bytes(('mtd_write write ' + version + ' Kernel'), encoding='utf8') tn.write(mtdwriteCmd + b'\n') tn.read_until(b'#') elif CPUmodel == 'P1010': mtdCmd = bytes(('tftp -gr mtd_write_p1010 ' + pcaddr + ' 69'), encoding='utf8') tn.write(mtdCmd + b'\n') tn.write(b'chmod 777 mtd_write_p1010' + b'\n') tn.read_until(b'#') mtdwriteCmd = bytes(('./mtd_write_p1010 write ' + version + ' Kernel'), encoding='utf8') tn.write(mtdwriteCmd + b'\n') tn.read_until(b'#') elif CPUmodel == 'X86': writeCmd = bytes(('dd if=' + version + ' of=/dev/sda'), encoding='utf8') tn.write(writeCmd + b'\n') tn.read_until(b'#') tn.write(b'ls' + b'\n') tn.read_until(b'#') #如果支持license 重置license分区且修改序列号为 licenseSN if license == '1': mtdwriteCmd = bytes(('tftp -gr license ' + pcaddr + ' 69'), encoding='utf8') tn.write(mtdwriteCmd + b'\n') tn.read_until(b'#') tn.write(b'dd if=license of=/dev/sda3' + b'\n') tn.read_until(b'#') mtdwriteCmd = bytes(('tftp -gr uttsn_x86_new ' + pcaddr + ' 69'), encoding='utf8') tn.write(mtdwriteCmd + b'\n') tn.read_until(b'#') tn.write(b'chmod 777 uttsn_x86_new' + b'\n') tn.read_until(b'#') mtdwriteCmd = bytes(('./uttsn_x86_new ' + licenseSN), encoding='utf8') tn.write(mtdwriteCmd + b'\n') tn.read_until(b'#') tn.write(b'reboot' + b'\n') time.sleep(40) win32process.TerminateProcess(handle[0], 0) # 关闭tftp32,注意脚本执行前关闭所有的tftp32进程 否则不能关闭会报错 i = 0 while i < 30: p = pingTestIP() if p == 'N': time.sleep(1) print(i) i += 1 else: time.sleep(10) # 多等待10s break else: logger.info(u'telnet更换软件后无法ping通 设备') raise Exception(u'telnet更换软件后无法ping通 设备')
def test_003_WirelessSecurity(self): u'''无线安全''' wificonfig = BasicConfigPage(self.driver, self.url) if str(support2).isdigit(): logger.info(u'参数2.4G无线') cpumodel = getCPUmodel() try: self.driver.implicitly_wait(2) wificonfig.click_wifiConfig() time.sleep(0.5) except AttributeError: CapPic(self.driver) logger.info(u'软件不支持无线配置,与参数表不符') raise Exception('软件不支持无线配置,与参数表不符') else: logger.info(u'软件支持无线配,与参数表相符') self.driver.implicitly_wait(10) wificonfig.click_BasicConfig() time.sleep(1) wificonfig.click_add() time.sleep(1) #主编码 wificonfig.input_ssid1('test') encodeType1 = wificonfig.selelement_byName(wificonfig.encodeType1) Select(encodeType1).select_by_value('GBK') time.sleep(0.2) Select(encodeType1).select_by_value('UTF-8') time.sleep(0.2) Select(encodeType1).select_by_value('BIG5') time.sleep(0.2) #备用编码 encodeType2 = wificonfig.selelement_byName(wificonfig.encodeType2) Select(encodeType2).select_by_value('GBK') time.sleep(0.2) Select(encodeType2).select_by_value('UTF-8') time.sleep(0.2) Select(encodeType2).select_by_value('BIG5') time.sleep(0.2) Select(encodeType2).select_by_value('NONE') time.sleep(0.2) #射频接口 wificonfig.click_fre2() if support5 != '--': try: self.driver.implicitly_wait(2) wificonfig.click_fre5() time.sleep(1) except AttributeError: CapPic(self.driver) logger.info(u'软件不支持5G,与参数表不符') raise Exception('软件不支持5G,与参数表不符') else: logger.info(u'软件支持5G,与参数表相符') else: logger.info(u'参数不支持5G无线') try: self.driver.implicitly_wait(2) wificonfig.click_fre5() except AttributeError: logger.info(u'软件不支持5G无线,与参数表相符') except NoSuchElementException: logger.info(u'软件不支持5G无线,与参数表相符') else: CapPic(self.driver) logger.info(u'软件支持5G无线,与参数表不符') raise Exception(u'软件支持5G无线,与参数表不符') self.driver.implicitly_wait(10) #接口名称 ifName = wificonfig.selelement_byName(wificonfig.ifName) Select(ifName).select_by_value('default') #高级选项 wificonfig.click_gjxx() time.sleep(0.5) #隐藏ssid wificonfig.click_broadcastEnablewEn() wificonfig.click_broadcastEnablewC() #无线客户端隔离 wificonfig.click_wlanClientIsolationEn() wificonfig.click_wlanClientIsolationC() #无线有线隔离 wificonfig.click_LanWlanSep1En() wificonfig.click_LanWlanSep1C() #安全设置 wificonfig.click_securitySet() time.sleep(1) secMode1 = wificonfig.selelement_byName(wificonfig.secMode1) Select(secMode1).select_by_value('NONE') time.sleep(0.2) if cpumodel == 'MTK': #高通暂不支持WEP Select(secMode1).select_by_value('WEP') time.sleep(0.2) wepAuthMode1 = wificonfig.selelement_byName( wificonfig.wepAuthMode1) Select(wepAuthMode1).select_by_value('OPEN') time.sleep(0.2) Select(wepAuthMode1).select_by_value('SHARED') time.sleep(0.2) Select(wepAuthMode1).select_by_value('WEPAUTO') time.sleep(0.2) Select(secMode1).select_by_value('WPA') time.sleep(0.5) wpaAuthMode1 = wificonfig.selelement_byName( wificonfig.wpaAuthMode1) Select(wpaAuthMode1).select_by_value('WPA') time.sleep(0.2) Select(wpaAuthMode1).select_by_value('WPA2') time.sleep(0.2) Select(wpaAuthMode1).select_by_value('WPA1WPA2') time.sleep(0.2) wpaCipher1 = wificonfig.selelement_byName(wificonfig.wpaCipher1) Select(wpaCipher1).select_by_value('TKIP') time.sleep(0.2) Select(wpaCipher1).select_by_value('AES') time.sleep(0.2) Select(wpaCipher1).select_by_value('TKIPAES') time.sleep(0.2) wificonfig.input_radiusIP('1.2.3.4') wificonfig.input_radiusPort('1814') wificonfig.input_radiusPsswd('12345678') wificonfig.input_keyUpdateCyc1('3000') Select(secMode1).select_by_value('WPAPSK') time.sleep(0.5) wpapskAuthMode1 = wificonfig.selelement_byName( wificonfig.wpapskAuthMode1) Select(wpapskAuthMode1).select_by_value('WPAPSKWPA2PSK') time.sleep(0.2) Select(wpapskAuthMode1).select_by_value('WPAPSK') time.sleep(0.2) Select(wpapskAuthMode1).select_by_value('WPA2PSK') time.sleep(0.2) wpapskCipher1 = wificonfig.selelement_byName( wificonfig.wpapskCipher1) Select(wpapskCipher1).select_by_value('TKIP') time.sleep(0.2) Select(wpapskCipher1).select_by_value('AES') time.sleep(0.2) Select(wpapskCipher1).select_by_value('TKIPAES') time.sleep(0.2) wificonfig.input_pskPsswd1('12345678') wificonfig.input_pskkeyUpdateCyc1('3000') # 带宽设置 wificonfig.click_Bandwidthset() time.sleep(0.5) wificonfig.click_share_sel1() wificonfig.click_share_sel2() wificonfig.input_rxBand1('1000') wificonfig.input_txBand1('2000') else: logger.info(u'参数不支持2.4G无线') try: self.driver.implicitly_wait(2) wificonfig.click_wifiConfig() except AttributeError: logger.info(u'软件不支持2.4G无线,与参数表相符') else: CapPic(self.driver) logger.info(u'软件支持2.4G无线,与参数表不符') raise Exception(u'软件支持2.4G无线,与参数表不符') self.driver.quit() logger.info('test_003_WirelessSecurity passed')
def test_ConfigGuide(self): u'''配置向导配置无线''' cpumodel = getCPUmodel() guide = ConfigGuidepage(self.driver, self.url) guide.click_configGuide() time.sleep(0.5) guide.click_next() time.sleep(1) # guide.click_next() #不修改接入方式 # time.sleep(1) try: self.driver.implicitly_wait(2) guide.click_next() except NoSuchElementException: CapPic(self.driver) logger.info(u'配置向导中,不支持wifi参数配置') raise Exception('配置向导中,不支持wifi参数配置') else: time.sleep(1) guide.input_ssid('test3_2.4') guide.input_passwd('12345678') channel = guide.selelement_byName(guide.channel) Select(channel).select_by_value('7') wrlessMode = guide.selelement_byName(guide.wrlessMode) chanWidth = guide.selelement_byName(guide.chanWidth) if cpumodel == 'MTK': Select(wrlessMode).select_by_value('6') #mtk 11n Select(chanWidth).select_by_value('2') #mtk为40M elif cpumodel == 'Qualcomm': Select(wrlessMode).select_by_value('1') #高通 11n Select(chanWidth).select_by_value('3') #高通 40M if support5 != '--': try: guide.find_ssid_5g() except NoSuchElementException: CapPic(self.driver) logger.info(u'不支持5G,与参数表不相符') raise Exception('不支持5G,与参数表不相符') guide.input_ssid_5g('test3_5') guide.input_passwd_5g('12345678') channel_5g = guide.selelement_byName(guide.channel_5g) Select(channel_5g).select_by_value('36') wrlessMode_5g = guide.selelement_byName(guide.wrlessMode_5g) chanWidth_5g = guide.selelement_byName(guide.chanWidth_5g) if cpumodel == 'MTK': Select(wrlessMode_5g).select_by_value('15') # mtk 11vht AC/AN Select(chanWidth_5g).select_by_value('2') # mtk为40M elif cpumodel == 'Qualcomm': Select(wrlessMode_5g).select_by_value('5') # 高通 11ac Select(chanWidth_5g).select_by_value('3') # 高通 HT40 guide.click_okey() time.sleep(35) self.driver.implicitly_wait(10) basicConfig = BasicConfigPage(self.driver, self.url) basicConfig.click_wifiConfig() time.sleep(0.5) basicConfig.click_BasicConfig() time.sleep(1) lsit_ssid1 = basicConfig.getText_byXpath(basicConfig.list_ssid1) self.assertEqual(lsit_ssid1, 'test3_2.4', msg='2.4G SSID保存异常') lsit_Mode1 = basicConfig.getText_byXpath(basicConfig.list_Mode1) self.assertEqual(lsit_Mode1, 'WPA-PSK/WPA2-PSK', msg='2.4G密码加密模式异常') list_wifipwd1 = basicConfig.getAttribute_byXpath( basicConfig.list_wifipwd1, 'data-local') self.assertEqual(list_wifipwd1, '12345678', msg='2.4G密码保存异常') tn = telnetlib.Telnet(host=host, port=port, timeout=10) #telnet验证 tn.set_debuglevel(5) tn.read_until(b'login:'******'Password:'******'#') if cpumodel == "MTK": tn.write( b'cat /etc/Wireless/RT2860/RT2860.dat | grep -E "SSID1|WPAPSK1"' + b'\n') elif cpumodel == "Qualcomm": tn.write( b'cat /etc/Wireless/wifi0/qca_ath0.dat | grep -E "ssid|key"' + b'\n') # 输出结果,判断 time.sleep(1) result = str(tn.read_very_eager()) # 只会存最后一条命令的结果 print('-------------------输出结果------------------------') # 命令执行结果 print('result:', result) # 判断 if cpumodel == "MTK": if "SSID1=test3_2.4" in result: print('2.4G SSID配置正常') else: raise Exception('2.4G SSID配置异常') if "WPAPSK1=12345678" in result: print('2.4G 密码配置正常') else: raise Exception('2.4G 密码配置异常') elif cpumodel == "Qualcomm": if "ssid=test3_2.4" in result: print('2.4G SSID配置正常') else: raise Exception('2.4G SSID配置异常') if "key=12345678" in result: print('2.4G 密码配置正常') else: raise Exception('2.4G 密码配置异常') tn.close() # tn.write('exit\n') if support5 != '--': time.sleep(5) try: lsit_ssid2 = basicConfig.getText_byXpath( basicConfig.list_ssid2) except NoSuchElementException: CapPic(self.driver) logger.info(u'不支持5G,与参数表不相符') raise Exception('不支持5G,与参数表不相符') self.assertEqual(lsit_ssid2, 'test3_5', msg='5G SSID保存异常') lsit_Mode2 = basicConfig.getText_byXpath(basicConfig.list_Mode2) self.assertEqual(lsit_Mode2, 'WPA-PSK/WPA2-PSK', msg='5G密码加密模式异常') list_wifipwd2 = basicConfig.getAttribute_byXpath( basicConfig.list_wifipwd2, 'data-local') self.assertEqual(list_wifipwd2, '12345678', msg='5G密码保存异常') tn = telnetlib.Telnet(host=host, port=port, timeout=10) # telnet验证 tn.set_debuglevel(5) tn.read_until(b'login:'******'Password:'******'#') if cpumodel == "MTK": tn.write( b'cat /etc/Wireless/iNIC/iNIC_ap.dat | grep -E "SSID1|WPAPSK1"' + b'\n') elif cpumodel == "Qualcomm": tn.write( b'cat /etc/Wireless/wifi1/qca_ath1.dat | grep -E "ssid|key"' + b'\n') # 输出结果,判断 time.sleep(1) result = str(tn.read_very_eager()) # 只会存最后一条命令的结果 print('-------------------输出结果------------------------') # 命令执行结果 print('result:', result) # 判断 if cpumodel == "MTK": if "SSID1=test3_5" in result: print('5G SSID配置正常') else: raise Exception('5G SSID配置异常') if "WPAPSK1=12345678" in result: print('5G 密码配置正常') else: raise Exception('5G 密码配置异常') elif cpumodel == "Qualcomm": if "ssid=test3_5" in result: print('5G SSID配置正常') else: raise Exception('5G SSID配置异常') if "key=12345678" in result: print('5G 密码配置正常') else: raise Exception('5G 密码配置异常') tn.close() # tn.write('exit\n') rfConfig = RFConfigPage(self.driver, self.url) rfConfig.click_RFConfig() time.sleep(1) if support5 != '--': channel2_7 = rfConfig.getAttribute_byXpath(rfConfig.channel2_7, 'selected') if cpumodel == "MTK": wrlessMode2_11n = rfConfig.getAttribute_byXpath( rfConfig.wrlessMode2_11nM, 'selected') chanWidth2_40 = rfConfig.getAttribute_byXpath( rfConfig.chanWidth2_40M, 'selected') elif cpumodel == "Qualcomm": wrlessMode2_11n = rfConfig.getAttribute_byXpath( rfConfig.wrlessMode2_11nQ, 'selected') chanWidth2_40 = rfConfig.getAttribute_byXpath( rfConfig.chanWidth2_40Q, 'selected') else: channel2_7 = rfConfig.getAttribute_byXpath(rfConfig.channel2_71, 'selected') if cpumodel == "MTK": wrlessMode2_11n = rfConfig.getAttribute_byXpath( rfConfig.wrlessMode2_11nM1, 'selected') chanWidth2_40 = rfConfig.getAttribute_byXpath( rfConfig.chanWidth2_40M1, 'selected') self.assertEqual(channel2_7, 'true', msg='2.4G信道不为7') self.assertEqual(wrlessMode2_11n, 'true', msg='2.4G模式不为11n') self.assertEqual(chanWidth2_40, 'true', msg='2.4G频宽不为40M') tn = telnetlib.Telnet(host=host, port=port, timeout=10) # telnet验证 tn.set_debuglevel(5) tn.read_until(b'login:'******'Password:'******'#') if cpumodel == "MTK": tn.write( b'cat /etc/Wireless/RT2860/RT2860.dat | grep -E "WirelessMode|Channel|HT_BW|HT_BSSCoexistence"' + b'\n') elif cpumodel == "Qualcomm": tn.write( b'cat /etc/Wireless/wifi0/qca_ath0.dat | grep -E "hwmode|channel|htmode"' + b'\n') # 输出结果,判断 time.sleep(1) result = str(tn.read_very_eager()) # 只会存最后一条命令的结果 print('-------------------输出结果------------------------') # 命令执行结果 print('result:', result) # 判断 if cpumodel == "MTK": if "WirelessMode=6" in result: #11n print('2.4G模式配置正常') else: raise Exception('2.4G模式配置异常') if "Channel=7" in result: print('2.4G信道配置正常') else: raise Exception('2.4G信道配置异常') if "HT_BW=1" and "HT_BSSCoexistence=0" in result: #40M print('2.4G频宽配置正常') else: raise Exception('2.4G频宽配置异常') elif cpumodel == "Qualcomm": if "hwmode=11n" in result: #11n print('2.4G模式配置正常') else: raise Exception('2.4G模式配置异常') if "channel=7" in result: print('2.4G信道配置正常') else: raise Exception('2.4G信道配置异常') if "htmode=HT40" in result: #40M print('2.4G频宽配置正常') else: raise Exception('2.4G频宽配置异常') tn.close() # tn.write('exit\n') if support5 != '--': try: if cpumodel == "MTK": wrlessMode5_15 = rfConfig.getAttribute_byXpath( rfConfig.wrlessMode5_15M, 'selected') elif cpumodel == "Qualcomm": wrlessMode5_15 = rfConfig.getAttribute_byXpath( rfConfig.wrlessMode5_15Q, 'selected') except NoSuchElementException: CapPic(self.driver) logger.info(u'不支持5G,与参数表不相符') raise Exception('不支持5G,与参数表不相符') self.assertEqual(wrlessMode5_15, 'true', msg='5G模式不为 11vht AC/AN') if languageA == 'English': channel5_36 = rfConfig.getAttribute_byXpath( rfConfig.channel5_36_2, 'selected') #英文版本多一个国家码 else: channel5_36 = rfConfig.getAttribute_byXpath( rfConfig.channel5_36, 'selected') self.assertEqual(channel5_36, 'true', msg='5G信道不为36') if cpumodel == "MTK": if languageA == 'English': chanWidth5_40 = rfConfig.getAttribute_byXpath( rfConfig.chanWidth5_40M_2, 'selected') else: chanWidth5_40 = rfConfig.getAttribute_byXpath( rfConfig.chanWidth5_40M, 'selected') elif cpumodel == "Qualcomm": if languageA == 'English': chanWidth5_40 = rfConfig.getAttribute_byXpath( rfConfig.chanWidth5_40Q_2, 'selected') else: chanWidth5_40 = rfConfig.getAttribute_byXpath( rfConfig.chanWidth5_40Q, 'selected') self.assertEqual(chanWidth5_40, 'true', msg='5G频宽不为40M') tn = telnetlib.Telnet(host=host, port=port, timeout=10) # telnet验证 tn.set_debuglevel(5) tn.read_until(b'login:'******'Password:'******'#') if cpumodel == "MTK": tn.write( b'cat /etc/Wireless/iNIC/iNIC_ap.dat | grep -E "WirelessMode|Channel|HT_BW|HT_BSSCoexistence"' + b'\n') # 无线隔离 elif cpumodel == "Qualcomm": tn.write( b'cat /etc/Wireless/wifi1/qca_ath1.dat | grep -E "hwmode|channel|htmode"' + b'\n') # 输出结果,判断 time.sleep(1) result = str(tn.read_very_eager()) # 只会存最后一条命令的结果 print('-------------------输出结果------------------------') # 命令执行结果 print('result:', result) # 判断 if cpumodel == "MTK": if "WirelessMode=15" in result: # mtk 11vht AC/AN print('5G模式配置正常') else: raise Exception('5G模式配置异常') if "Channel=36" in result: print('5G信道配置正常') else: raise Exception('5G信道配置异常') if "HT_BW=1" and "HT_BSSCoexistence=0" in result: # 40M print('5G频宽配置正常') else: raise Exception('5G频宽配置异常') elif cpumodel == "Qualcomm": if "hwmode=11ac" in result: # mtk 11vht AC/AN print('5G模式配置正常') else: raise Exception('5G模式配置异常') if "channel=36" in result: print('5G信道配置正常') else: raise Exception('5G信道配置异常') if "htmode=HT40" in result: # 40M print('5G频宽配置正常') else: raise Exception('5G频宽配置异常') tn.close() # tn.write('exit\n') self.driver.quit() logger.info('test_ConfigGuide passed')