def test_001_information(self): u'''默认关闭,网络名称、设备管理页面提示正确''' wirelessTipsA = getAssertText('wirelessTipsA') netname = netNamePage(self.driver, self.url) #网络名称页面的提示 netname.click_netName() time.sleep(1) boxtips = netname.getText_byClass(netname.u_cfm_boxT) if wirelessTipsA not in boxtips: CapPic(self.driver) logger.info(u'网络名称页面 无线扩展提示有误') raise Exception('网络名称页面 无线扩展提示有误') netname.click_u_cfm_nox() #提示窗右上角×号 time.sleep(1) #确认按钮默认关闭 checkOpens = netname.getAttribute_byId(netname.checkOpens, 'checktype') self.assertEqual(checkOpens, '0', msg='无限扩展默认未关闭') #0关闭,1打开 # 设备管理页面的提示 device = deviceMgmtPage(self.driver, self.url) device.click_deviceMgmt() time.sleep(1) boxtips = netname.getText_byClass(netname.u_cfm_boxT) if wirelessTipsA not in boxtips: CapPic(self.driver) logger.info(u'设备管理页面 无线扩展提示有误') raise Exception('设备管理页面 无线扩展提示有误') device.click_no() #取消按钮 time.sleep(1) self.driver.quit() logger.info('test_001_information passed')
def setUp(self): logger.info('setUp start') login.loginWeb(self) #admin账号登录 self.driver.implicitly_wait(10) netname = netNamePage(self.driver, self.url) #进入无线扩展 try: netname.click_wirelessExtension() time.sleep(0.5) except AttributeError: raise Exception(u'软件不支持无线扩展')
def test_003_AutoSend(self): u'''网络名称 默认自动下发''' netname = netNamePage(self.driver, self.url) netname.click_wirelessExtension() time.sleep(0.5) netname.click_netName() time.sleep(1) list_autosend1 = str(netname.getAttribute_byXpath(netname.list_autosend1,'checked')) self.assertEqual(list_autosend1,'true',msg='默认自动下发 未开启') self.driver.quit() logger.info('test_003_AutoSend passed')
def test_002_editDelSSID(self): u'''网络名称修改、删除''' netname = netNamePage(self.driver, self.url) # 修改网络名称 netname.click_wirelessExtension() time.sleep(0.5) netname.click_netName() time.sleep(1) #编辑第4个ssid netname.click_list_edit4() time.sleep(1) netname.input_ssid('ssid_all中2') netname.click_next_tab() time.sleep(0.5) netname.click_next_tab() time.sleep(0.5) netname.click_save() time.sleep(1) list_ssid4 = str(netname.getText_byXpath(netname.list_ssid4)) self.assertEqual(list_ssid4, 'ssid_all中2', msg='ssid4 与修改不一致') #删除 netname.click_list_del4() time.sleep(1) netname.click_ok() time.sleep(1) list_nodata4 = str(netname.getText_byXpath(netname.list_nodata4)) if list_nodata4 == '' or ' ': print('ssid 删除成功') else: CapPic(self.driver) logger.info(u'ssid 删除失败') raise Exception('删除失败') # 再新增第四个ssid netname.click_add() time.sleep(1) netname.input_zoneName('all') netname.input_ssid('ssid_all中') netname.click_next_tab() time.sleep(0.5) netname.click_next_tab() time.sleep(0.5) netname.click_save() time.sleep(1) list_ssid4 = str(netname.getText_byXpath(netname.list_ssid4)) self.assertEqual(list_ssid4, 'ssid_all中', msg='ssid4 与设置不一致') self.driver.quit() logger.info('test_002_editDelSSID passed')
def test_001_APconfig(self): u'''AP配置管理''' wirelessTipsA = getAssertText('wirelessTipsA') OnlineA = getAssertText('OnlineA') Support5GAP = getweb('Support5GAP') #环境中支持5G的AP login.loginWeb(self) self.driver.implicitly_wait(10) # 先进入网络名称 判断无线扩展是否打开 netname = netNamePage(self.driver, self.url) # print(Support) if str(Support).isdigit(): #判断字符串是否为数字 logger.info(u'参数支持AP管理') try: self.driver.implicitly_wait(2) netname.click_wirelessExtension() time.sleep(0.5) netname.click_netName() time.sleep(1) except AttributeError or NoSuchElementException: CapPic(self.driver) logger.info(u'软件不支持无线扩展/网络名称,与参数表不符') raise Exception(u'软件不支持无线扩展/网络名称,与参数表不符') else: logger.info(u'软件支持无线扩展,与参数表相符') self.driver.implicitly_wait(10) checkOpen = str( netname.getAttribute_byId(netname.checkOpens, 'checktype')) ManageProtocols = str( netname.getAttribute_byId(netname.ManageProtocolss, 'checktype')) if checkOpen == '0': # 0为关闭,1打开 tips = netname.getText_byClass(netname.u_cfm_boxT) time.sleep(1) self.assertIn(wirelessTipsA, tips, msg='提示信息有误') netname.click_ok() # 点确认开启 time.sleep(30) #等AP上线 时间久一点 else: time.sleep(5) # 002中打开 等待时间稍短一些 if ManageProtocols == '0': # 0为关闭,1打开 netname.click_ManageProtocols() # 开启 time.sleep(10) #等v1AP上线 # 断言 开关打开 checkOpen = str( netname.getAttribute_byId(netname.checkOpens, 'checktype')) self.assertEqual(checkOpen, '1', msg='无线扩展默认未打开') # 0关闭,1打开 ManageProtocols = str( netname.getAttribute_byId(netname.ManageProtocolss, 'checktype')) self.assertEqual(ManageProtocols, '1', msg='兼容模式未打开') #进入设备管理 device = deviceMgmtPage(self.driver, self.url) device.click_deviceMgmt() time.sleep(1) #判断AP已正常上线 x = 0 while x < 120: device.click_refreshtable() time.sleep(1) list_status1 = device.getText_byXpath(device.list_status1) list_status2 = device.getText_byXpath(device.list_status2) list_status3 = device.getText_byXpath(device.list_status3) list_status4 = device.getText_byXpath(device.list_status4) print(list_status1, list_status2, list_status3, list_status4, x) if list_status1 == OnlineA and list_status2 == OnlineA and list_status3 == OnlineA and list_status4 == OnlineA: print('4台AP均在线', x) channel1 = str( device.getAttribute_byXpath( device.list_channel1, 'data-local')) channel2 = str( device.getAttribute_byXpath( device.list_channel2, 'data-local')) channel3 = str( device.getAttribute_byXpath( device.list_channel3, 'data-local')) channel4 = str( device.getAttribute_byXpath( device.list_channel4, 'data-local')) print('channel1=', channel1, 'channel2=', channel2, 'channel3=', channel3, 'channel4=', channel4, x) if channel1 != '' and channel2 != '' and channel3 != '' and channel4 != '': print('4台AP2.4G无线接口已同步', x) break else: time.sleep(3) else: time.sleep(3) x = x + 1 else: raise Exception('AP 未能同步2.4G无线接口') #需选择一个同时支持2.4G 5G的AP 并搜索 device.input_search(Support5GAP) device.click_searchB() time.sleep(1) device.click_list_name1() time.sleep(0.5) device.input_list_namein1('1') time.sleep(0.5) device.find_list_nameS1() #2.4G 信道 device.click_list_channel1c() time.sleep(0.5) select_2 = device.selelement_byXpath(device.selchannel2_1) Select(select_2).select_by_value('1') time.sleep(0.2) Select(select_2).select_by_value('2') time.sleep(0.2) Select(select_2).select_by_value('3') time.sleep(0.2) Select(select_2).select_by_value('4') time.sleep(0.2) Select(select_2).select_by_value('5') time.sleep(0.2) Select(select_2).select_by_value('6') time.sleep(0.2) Select(select_2).select_by_value('7') time.sleep(0.2) Select(select_2).select_by_value('8') time.sleep(0.2) Select(select_2).select_by_value('9') time.sleep(0.2) Select(select_2).select_by_value('10') time.sleep(0.2) Select(select_2).select_by_value('11') time.sleep(0.2) Select(select_2).select_by_value('auto') time.sleep(0.2) device.find_selchannel2S_1() #5G device.click_list_channel51c() time.sleep(0.5) select_5 = device.selelement_byXpath(device.selchannel5_1) Select(select_5).select_by_value('36') time.sleep(0.2) Select(select_5).select_by_value('40') time.sleep(0.2) Select(select_5).select_by_value('44') time.sleep(0.2) Select(select_5).select_by_value('48') time.sleep(0.2) Select(select_5).select_by_value('149') time.sleep(0.2) Select(select_5).select_by_value('153') time.sleep(0.2) Select(select_5).select_by_value('157') time.sleep(0.2) Select(select_5).select_by_value('161') time.sleep(0.2) Select(select_5).select_by_value('165') time.sleep(0.2) Select(select_5).select_by_value('auto') time.sleep(0.2) device.find_selchannel5S_1() #漫游阈值 device.click_deviceMgmt() time.sleep(1) device.click_list_mangement1() time.sleep(2) device.click_modifyPw() #修改密码 time.sleep(0.2) device.click_roamingSet() time.sleep(0.5) # rpaming_en_2G = str(device.getAttribute_byXpath(device.roaming_cs,'checked')) # self.assertEqual(rpaming_en_2G,'true',msg='2.4G漫游阈值 默认未关闭') device.click_roaming_en() time.sleep(0.5) device.input_roaming_th('-80') time.sleep(0.2) # rpaming_en_5G = str(device.getAttribute_byXpath(device.roaming_c5s,'checked')) # self.assertEqual(rpaming_en_5G, 'true', msg='5G漫游阈值 默认未关闭') device.click_roaming_en5() time.sleep(0.5) device.input_roaming_th5('-80') time.sleep(0.2) device.click_modal_hide() time.sleep(1) #重启 device.find_list_reboot1() #批量管理 device.click_list_sel1() device.click_BatchManagement() time.sleep(2) #射频模板 spmb = device.selelement_byName(device.spmb) Select(spmb).select_by_value('default2') time.sleep(0.2) Select(spmb).select_by_value('default1') time.sleep(0.2) Select(spmb).select_by_value('default3') time.sleep(0.2) #网络名称 device.click_ssidM() time.sleep(1) device.click_list_selwn1() device.click_selall_w() device.find_sendToApM() #系统设置 device.click_Syssetup() time.sleep(1) device.click_TaskS_En() #计划任务 time.sleep(0.2) device.click_TaskS_C() time.sleep(0.2) device.click_sleepMode_En() # 睡眠模式 time.sleep(0.2) device.click_sleepMode_C() time.sleep(0.2) # 配置重启 device.click_configreboot() time.sleep(0.5) device.find_restart() device.find_factory_reset() device.click_close() time.sleep(0.5) #备份配置 device.click_backupconfig() time.sleep(1) device.find_allDelete() device.find_backup() device.find_uploadBackup() #软件升级 apsoftware = APSoftwarePage(self.driver, self.url) apsoftware.click_APsoftware() time.sleep(1) apsoftware.find_checkUpdata() apsoftware.find_upData() apsoftware.find_upDataLocal() else: logger.info(u'参数不支持AP管理') try: self.driver.implicitly_wait(2) netname.click_wirelessExtension() time.sleep(0.5) netname.click_netName() time.sleep(1) except AttributeError or NoSuchElementException: logger.info(u'软件不支持无线扩展,与参数表相符') else: CapPic(self.driver) logger.info(u'软件支持无线扩展,与参数表不符') raise Exception(u'软件支持无线扩展,与参数表不符') self.driver.quit() logger.info('test_001_APconfig passed')
def test_002_SSIDconfig(self): u'''网络名称设置&加密方式''' APnumP = getParameter('APnumP') Support = getExcelValue(APnumP) login.loginWeb(self) self.driver.implicitly_wait(10) if str(Support).isdigit(): #判断字符串是否为数字 logger.info(u'参数支持AP管理') wirelessTipsA = getAssertText('wirelessTipsA') vlanPortP = getParameter('vlanPortP') Support = getExcelValue(vlanPortP) if Support == '√': # 支持vlan接口 logger.info(u'参数表支持vlan接口') # 进入网络配置-内网配置 配置vlan接口 lanpage = NetworkConfig_LANpage(self.driver, self.url) lanpage.click_NetworkConfig() time.sleep(0.5) lanpage.click_LANconfig() time.sleep(1) #vlan 1000 lanpage.click_add() time.sleep(1) lanpage.input_lanIpName('1000') lanpage.input_lanIp('192.168.10.1') lanpage.input_lanNetmask('255.255.255.0') selsxjk = lanpage.selelement_byName(lanpage.selsxjk) Select(selsxjk).select_by_value('vlanid') time.sleep(1) lanpage.input_dhcpVid('1000') lanpage.click_save() time.sleep(1) # vlan 1999 lanpage.click_add() time.sleep(1) lanpage.input_lanIpName('1999') lanpage.input_lanIp('192.168.100.1') lanpage.input_lanNetmask('255.255.255.0') selsxjk = lanpage.selelement_byName(lanpage.selsxjk) Select(selsxjk).select_by_value('vlanid') time.sleep(1) lanpage.input_dhcpVid('1999') lanpage.click_save() time.sleep(1) #断言 list_name2 = str(lanpage.getText_byXpath(lanpage.list_name2)) list_name3 = str(lanpage.getText_byXpath(lanpage.list_name3)) list_ip2 = str(lanpage.getText_byXpath(lanpage.list_ip2)) list_ip3 = str(lanpage.getText_byXpath(lanpage.list_ip3)) list_vlanid2 = str( lanpage.getText_byXpath(lanpage.list_vlanid2)) list_vlanid3 = str( lanpage.getText_byXpath(lanpage.list_vlanid3)) self.assertEqual(list_name2, '1000', msg='vlan1000名称与设置的不一致') self.assertEqual(list_name3, '1999', msg='vlan1999名称与设置的不一致') self.assertEqual(list_ip2, '192.168.10.1', msg='vlan1000IP与设置的不一致') self.assertEqual(list_ip3, '192.168.100.1', msg='vlan1000IP与设置的不一致') self.assertEqual(list_vlanid2, '1000', msg='vlan1000 ID与设置的不一致') self.assertEqual(list_vlanid3, '1999', msg='vlan1000 ID与设置的不一致') #配置dhcp dhcppage = DHCPserverpage(self.driver, self.url) #1000 dhcppage.click_DHCPserver() time.sleep(1) dhcppage.click_addpool() time.sleep(1) dhcppage.input_poolName('1000') seldhcppool = dhcppage.selelement_byName(dhcppage.poolVid) Select(seldhcppool).select_by_value('VIF1000') time.sleep(1) dhcppage.click_save() time.sleep(1) # 1999 dhcppage.click_DHCPserver() time.sleep(1) dhcppage.click_addpool() time.sleep(1) dhcppage.input_poolName('1999') seldhcppool = dhcppage.selelement_byName(dhcppage.poolVid) Select(seldhcppool).select_by_value('VIF1999') time.sleep(1) dhcppage.click_save() time.sleep(1) # 断言 list_name2 = str(dhcppage.getText_byXpath(dhcppage.list_name2)) list_name3 = str(dhcppage.getText_byXpath(dhcppage.list_name3)) list_int2 = str(dhcppage.getText_byXpath(dhcppage.list_int2)) list_int3 = str(dhcppage.getText_byXpath(dhcppage.list_int3)) self.assertEqual(list_name2, '1000', msg='pool1000名称与设置的不一致') self.assertEqual(list_name3, '1999', msg='pool1999名称与设置的不一致') self.assertEqual(list_int2, '1000', msg='pool1000IP与设置的不一致') self.assertEqual(list_int3, '1999', msg='pool1000IP与设置的不一致') # 配置网络名称 netname = netNamePage(self.driver, self.url) try: self.driver.implicitly_wait(2) netname.click_wirelessExtension() time.sleep(0.5) #网络名称页面的提示 netname.click_netName() except AttributeError or NoSuchElementException: CapPic(self.driver) logger.info(u'软件不支持无线扩展/网络名称,与参数表不符') raise Exception(u'软件不支持无线扩展/网络名称,与参数表不符') else: self.driver.implicitly_wait(10) time.sleep(1) checkOpen = str( netname.getAttribute_byId(netname.checkOpens, 'checktype')) if checkOpen == '0': # 0为关闭,1打开 tips = netname.getText_byClass(netname.u_cfm_boxT) time.sleep(1) self.assertIn(wirelessTipsA, tips, msg='提示信息有误') netname.click_ok() # 点确认开启 time.sleep(3) else: raise Exception('无线扩展默认未关闭') # 断言 开关打开 checkOpen = str( netname.getAttribute_byId(netname.checkOpens, 'checktype')) self.assertEqual(checkOpen, '1', msg='无线扩展默认未关闭') # 0关闭,1打开 # 确认兼容模式按钮默认关闭 ManageProtocols = str( netname.getAttribute_byId(netname.ManageProtocolss, 'checktype')) self.assertEqual(ManageProtocols, '0', msg='兼容模式默认未关闭') # 0关闭,1打开 # 打开兼容模式 netname.click_ManageProtocols() time.sleep(5) ManageProtocols = str( netname.getAttribute_byId(netname.ManageProtocolss, 'checktype')) self.assertEqual(ManageProtocols, '1', msg='兼容模式未打开') # 0关闭,1打开 #判断自动下发是否开启 Auto = str( netname.getAttribute_byXpath(netname.list_autosend1, 'checked')) self.assertEqual(str(Auto), 'true', msg='默认自动下发未开启') # 编辑默认ssid netname.click_list_edit1() time.sleep(1) netname.input_ssid('ssid_1中') netname.click_next_tab() time.sleep(1) selencryType = netname.selelement_byName(netname.encryType) Select(selencryType).select_by_value( '1') # 0不加密 3 WPA-PSK/WPA2-PSK time.sleep(0.3) Select(selencryType).select_by_value('0') time.sleep(0.3) Select(selencryType).select_by_value('2') time.sleep(0.3) Select(selencryType).select_by_value('3') time.sleep(0.5) netname.input_pskPsswd('12345678') netname.click_next_tab() time.sleep(0.5) netname.click_sharelimit() # 共享 netname.input_txBand('1000') netname.input_rxBand('1000') netname.click_save() time.sleep(1) list_ssid1 = str(netname.getText_byXpath(netname.list_ssid1)) self.assertEqual(list_ssid1, 'ssid_1中', msg='ssid1 与设置不一致') # 新增2Gssid netname.click_add() time.sleep(1) netname.input_zoneName('2G') netname.input_ssid('2.4Gz中') netname.click_cli_5g() # 默认全选,点5G=勾掉,剩下2.4G if Support == '√': # 支持vlan接口 selvlanId = netname.selelement_byName( netname.vlanId) # 选vlan接口 Select(selvlanId).select_by_value('1000') time.sleep(1) netname.click_gjxx() # 点开高级选项 time.sleep(0.5) netname.click_broadcastEn() # 隐藏ssid netname.click_isolateEn() # 无线客户端隔离 time.sleep(0.5) netname.click_next_tab() time.sleep(1) selencryType = netname.selelement_byName(netname.encryType) Select(selencryType).select_by_value( '3') # 0不加密 3 WPA-PSK/WPA2-PSK time.sleep(1) netname.input_pskPsswd('12345678') netname.click_next_tab() time.sleep(0.5) netname.input_txBand('1000') netname.input_rxBand('1000') netname.click_save() time.sleep(2) # 断言 开关打开 list_ssid2 = str(netname.getText_byXpath(netname.list_ssid2)) self.assertEqual(list_ssid2, '2.4Gz中', msg='ssid2 与设置不一致') # 新增5Gssid netname.click_add() time.sleep(1) netname.input_zoneName('5G') netname.input_ssid('5Gz中') selSSIDmode = netname.selelement_byName(netname.encodeType) Select(selSSIDmode).select_by_value('0') #0电脑优先 1手机优先 time.sleep(1) netname.click_cli_2g() # 默认全选,点2G=勾掉,剩下5G if Support == '√': # 支持vlan接口 selvlanId = netname.selelement_byName( netname.vlanId) # 选vlan接口 Select(selvlanId).select_by_value('1999') time.sleep(1) netname.click_gjxx() # 点开高级选项 time.sleep(0.5) netname.click_broadcastEn() # 隐藏ssid netname.click_isolateEn() # 无线客户端隔离 time.sleep(0.5) netname.click_next_tab() time.sleep(1) selencryType = netname.selelement_byName(netname.encryType) Select(selencryType).select_by_value( '3') # 0不加密 3 WPA-PSK/WPA2-PSK time.sleep(1) netname.input_pskPsswd('12345678') netname.click_next_tab() time.sleep(0.5) netname.input_txBand('1000') netname.input_rxBand('1000') netname.click_save() time.sleep(1) list_ssid3 = str(netname.getText_byXpath(netname.list_ssid3)) self.assertEqual(list_ssid3, '5Gz中', msg='ssid3 与设置不一致') # 新增默认接口ssid netname.click_add() time.sleep(1) netname.input_zoneName('all') netname.input_ssid('ssid_all中') netname.click_next_tab() time.sleep(0.5) netname.click_next_tab() time.sleep(0.5) netname.click_save() time.sleep(1) # 断言 list_ssid4 = str(netname.getText_byXpath(netname.list_ssid4)) self.assertEqual(list_ssid4, 'ssid_all中', msg='ssid4 与设置不一致') #再新建提示保存成功(ssid数量后续版本做了调整) netname.click_add() time.sleep(1) netname.input_zoneName('5') netname.input_ssid('5') netname.click_next_tab() time.sleep(0.5) netname.click_next_tab() time.sleep(0.5) netname.click_save() time.sleep(1) # 断言 开关打开 list_ssid5 = str(netname.getText_byXpath(netname.list_ssid5)) self.assertEqual(list_ssid5, '5', msg='ssid5 与设置不一致') print('网络名称设置 验证通过') #删除ssid netname.click_selall() time.sleep(0.2) netname.click_sellist1() time.sleep(0.2) netname.click_delete() time.sleep(2) netname.click_ok() time.sleep(1) if Support == '√': # 支持vlan接口 # 删除dhcp dhcppage = DHCPserverpage(self.driver, self.url) dhcppage.click_NetworkConfig() time.sleep(0.5) dhcppage.click_DHCPserver() time.sleep(0.5) dhcppage.click_DHCPserver() time.sleep(1) dhcppage.click_list_delpool2() time.sleep(1) dhcppage.click_ok() time.sleep(1) dhcppage.click_list_delpool2() time.sleep(1) dhcppage.click_ok() time.sleep(1) # 删除vlan接口 lanpage = NetworkConfig_LANpage(self.driver, self.url) lanpage.click_LANconfig() time.sleep(1) lanpage.click_allsel() time.sleep(1) lanpage.click_delete() time.sleep(1) lanpage.click_ok() time.sleep(1) else: logger.info(u'参数不支持AP管理') try: netname = netNamePage(self.driver, self.url) self.driver.implicitly_wait(2) netname.click_wirelessExtension() time.sleep(0.5) netname.click_netName() time.sleep(1) except AttributeError or NoSuchElementException: logger.info(u'软件不支持无线扩展,与参数表相符') else: CapPic(self.driver) logger.info(u'软件支持无线扩展,与参数表不符') raise Exception(u'软件支持无线扩展,与参数表不符') self.driver.quit() logger.info('test_002_SSIDconfig passed')
def test_001_configlist(self): u'''配置文件列表显示''' OnlineA = getAssertText('OnlineA') login.loginWeb(self) self.driver.implicitly_wait(10) netname = netNamePage(self.driver, self.url) netname.click_wirelessExtension() time.sleep(0.5) netname.click_netName() time.sleep(1) try: self.driver.implicitly_wait(3) netname.find_ok() except NoSuchElementException: pass else: print('打开无线扩展,等待AP上线') time.sleep(5) ManageProtocol = netname.getAttribute_byId( netname.ManageProtocolss, 'checktype') if ManageProtocol == '0': # 1为打开 0为关闭 开启兼容模式 netname.click_ManageProtocols() print('打开兼容模式,等待AP上线') time.sleep(70) self.driver.implicitly_wait(10) configlist = deviceMgmtPage(self.driver, self.url) configlist.click_deviceMgmt() time.sleep(5) # 确认在线AP序列号,确认配置文件列表中包含有对应ap的配置文件 # 先确认AP在线 x = 0 while x < 100: configlist.click_refreshtable() time.sleep(1) list_status1 = configlist.getText_byXpath(configlist.list_status1) list_status2 = configlist.getText_byXpath(configlist.list_status2) list_status3 = configlist.getText_byXpath(configlist.list_status3) list_status4 = configlist.getText_byXpath(configlist.list_status4) print(list_status1, list_status2, list_status3, list_status4, x) if list_status1 == OnlineA and list_status2 == OnlineA and list_status3 == OnlineA and list_status4 == OnlineA: print('4台AP均在线', x) channel1 = str( configlist.getAttribute_byXpath(configlist.list_channel1, 'data-local')) channel2 = str( configlist.getAttribute_byXpath(configlist.list_channel2, 'data-local')) channel3 = str( configlist.getAttribute_byXpath(configlist.list_channel3, 'data-local')) channel4 = str( configlist.getAttribute_byXpath(configlist.list_channel4, 'data-local')) print('channel1=', channel1, 'channel2=', channel2, 'channel3=', channel3, 'channel4=', channel4, x) if channel1 != '' and channel2 != '' and channel3 != '' and channel4 != '': print('4台AP2.4G无线接口已同步', x) break else: time.sleep(3) else: time.sleep(3) x = x + 1 else: raise Exception('AP 未能同步2.4G无线接口') #确认AP序列号 APseq1 = configlist.getText_byXpath(configlist.list_seq1) APseq2 = configlist.getText_byXpath(configlist.list_seq2) APseq3 = configlist.getText_byXpath(configlist.list_seq3) APseq4 = configlist.getText_byXpath(configlist.list_seq4) APModel1 = configlist.getText_byXpath(configlist.list_modes1) APModel2 = configlist.getText_byXpath(configlist.list_modes2) APmodel3 = configlist.getText_byXpath(configlist.list_modes3) APModel4 = configlist.getText_byXpath(configlist.list_modes4) configlist.click_backupconfig() time.sleep(1) configlist.input_searchBack(APseq1) configlist.click_searchBackb() time.sleep(1) try: list_seqnum = str( configlist.getText_byXpath(configlist.bconfigseq1)) self.assertEqual(list_seqnum, APseq1, msg='seqnum1 序列号不一致') list_model = str( configlist.getText_byXpath(configlist.bconfigmodel1)) self.assertEqual(list_model, APModel1, msg='model1 型号不一致') configlist.input_searchBack(APseq2) configlist.click_searchBackb() time.sleep(1) list_seqnum = str( configlist.getText_byXpath(configlist.bconfigseq1)) self.assertEqual(list_seqnum, APseq2, msg='seqnum2 序列号不一致') list_model = str( configlist.getText_byXpath(configlist.bconfigmodel1)) self.assertEqual(list_model, APModel2, msg='model2 型号不一致') except NoSuchElementException: logger.info(u'v2AP配置文件不存在') CapPic(self.driver) raise Exception(u'v2AP配置文件不存在') configlist.input_searchBack(APseq3) configlist.click_searchBackb() time.sleep(1) try: list_seqnum = str( configlist.getText_byXpath(configlist.bconfigseq1)) self.assertEqual(list_seqnum, APseq3, msg='seqnum3 序列号不一致') list_model = str( configlist.getText_byXpath(configlist.bconfigmodel1)) self.assertEqual(list_model, APmodel3, msg='model3 型号不一致') configlist.input_searchBack(APseq4) configlist.click_searchBackb() time.sleep(1) list_seqnum = str( configlist.getText_byXpath(configlist.bconfigseq1)) self.assertEqual(list_seqnum, APseq4, msg='seqnum4 序列号不一致') list_model = str( configlist.getText_byXpath(configlist.bconfigmodel1)) self.assertEqual(list_model, APModel4, msg='mode4 型号不一致') except NoSuchElementException: logger.info(u'v1AP配置文件不存在') CapPic(self.driver) raise Exception(u'v1AP配置文件不存在') self.driver.quit() logger.info('test_001_configlist passed')
def test_002_ExpansionSW(self): u'''开启、关闭 无线扩展 正常''' nodata = getAssertText('nodata') OnlineA = getAssertText('OnlineA') OfflineA = getAssertText('OfflineA') device = deviceMgmtPage(self.driver, self.url) device.click_deviceMgmt() time.sleep(1) device.click_no() # 取消按钮 time.sleep(1) list_nodata = device.getText_byXpath(device.list_nodata) self.assertEqual(list_nodata, nodata, msg='未开启开关 设备管理列表显示有误') netname = netNamePage(self.driver, self.url) netname.click_netName() time.sleep(1) netname.click_ok() # 点确认开启 time.sleep(1) checkOpens = netname.getAttribute_byId(netname.checkOpens, 'checktype') self.assertEqual(checkOpens, '1', msg='无线扩展默认未打开') # 0关闭,1打开 #发现AP device = deviceMgmtPage(self.driver, self.url) device.click_deviceMgmt() time.sleep(15) device.click_refreshtable() time.sleep(1) x = 0 while x < 100: device.click_refreshtable() time.sleep(1) list_state1 = device.getText_byXpath(device.list_state1) if str(list_state1) == OnlineA or OfflineA: print('扩展开启 验证通过') break else: time.sleep(3) x = x + 1 else: raise Exception('扩展打开 未发现AP上线') #关闭无线拓展 netname = netNamePage(self.driver, self.url) netname.click_netName() time.sleep(1) netname.click_checkOpen() time.sleep(1) # 断言 开关关闭 checkOpens = netname.getAttribute_byId(netname.checkOpens, 'checktype') self.assertEqual(checkOpens, '0', msg='无线扩展默认未关闭') # 0关闭,1打开 # AP列表为空 device = deviceMgmtPage(self.driver, self.url) device.click_deviceMgmt() time.sleep(1) list_nodata = device.getText_byXpath(device.list_nodata) self.assertEqual(list_nodata, nodata, msg='关闭开关 列表显示有误') print('扩展关闭 验证通过') #再打开无线扩展 netname.click_ok() # 点确认开启 time.sleep(1) self.driver.quit() logger.info('test_002_ExpansionSW passed')
def test_003_ProtocolSW(self): u'''开启、关闭 兼容模式 ''' netname = netNamePage(self.driver, self.url) netname.click_netName() time.sleep(1) # 兼容模式 默认关闭 ManageProtocol = netname.getAttribute_byId(netname.ManageProtocolss, 'checktype') self.assertEqual(ManageProtocol, '0', msg='兼容模式未关闭') # 0关闭,1打开 # 打开兼容模式 netname.click_ManageProtocols() time.sleep(5) ManageProtocol = netname.getAttribute_byId(netname.ManageProtocolss, 'checktype') self.assertEqual(ManageProtocol, '1', msg='兼容模式未打开') # 0关闭,1打开 # 确认打开后有acd进程 hostip = gettelnet('host') port = gettelnet('port') username = bytes(getweb('User'), encoding="utf8") password = bytes(getweb('Passwd'), encoding="utf8") tn = telnetlib.Telnet(host=hostip, port=port) tn.set_debuglevel(5) # 级别越高输出的调试信息越多,并没有看出区别 # 输入登录用户名 tn.read_until(b'login:'******'Password:'******'#') tn.write(b'ps | grep -v grep |grep acd' + b'\n') # SSID加密密码 # 输出结果,判断 time.sleep(1) result = str(tn.read_very_eager()) # 只会存最后一条命令的结果 print('-------------------输出结果------------------------') # 命令执行结果 print('result:', result) # 判断 if "/sbin/acd_guard.sh " in result: print('acd进程存在') else: raise Exception('打开兼容模式后 acd进程未存在') # 如果没有则报错 tn.close() # tn.write('exit\n') #关闭兼容模式 netname.click_ManageProtocols() time.sleep(2) ManageProtocol = netname.getAttribute_byId(netname.ManageProtocolss, 'checktype') self.assertEqual(ManageProtocol, '0', msg='兼容模式未关闭') # 0关闭,1打开 # 确认关闭后没有acd进程 tn = telnetlib.Telnet(host=hostip, port=port) tn.set_debuglevel(5) # 级别越高输出的调试信息越多,并没有看出区别 # 输入登录用户名 tn.read_until(b'login:'******'Password:'******'#') tn.write(b'ps | grep -v grep |grep acd' + b'\n') # SSID加密密码 # 输出结果,判断 time.sleep(1) result = str(tn.read_very_eager()) # 只会存最后一条命令的结果 print('-------------------输出结果------------------------') # 命令执行结果 print('result:', result) # 判断 if "/sbin/acd_guard.sh " not in result: print('acd进程不存在') else: raise Exception('关闭兼容模式后 acd进程依旧存在') # 如果没有则报错 tn.close() # tn.write('exit\n') # 再打开兼容模式 netname.click_ManageProtocols() time.sleep(2) ManageProtocol = netname.getAttribute_byId(netname.ManageProtocolss, 'checktype') self.assertEqual(ManageProtocol, '1', msg='兼容模式未打开') # 0关闭,1打开 self.driver.quit() logger.info('test_003_ProtocolSW passed')
def test_001_ssidNum(self): u'''网络名称添加''' vlanPortP = getParameter('vlanPortP') Support = getExcelValue(vlanPortP) if Support == '√': #支持vlan接口 logger.info(u'参数表支持vlan接口') lanpage = NetworkConfig_LANpage(self.driver,self.url) # 进入网络配置-外网配置 配置vlan接口 lanpage.click_NetworkConfig() time.sleep(0.5) lanpage.click_LANconfig() time.sleep(1) #vlan 1000 lanpage.click_add() time.sleep(1) lanpage.input_lanIpName('1000') lanpage.input_lanIp('192.168.10.1') lanpage.input_lanNetmask('255.255.255.0') selsxjk = lanpage.selelement_byName(lanpage.selsxjk) Select(selsxjk).select_by_value('vlanid') time.sleep(1) lanpage.input_dhcpVid('1000') lanpage.click_save() time.sleep(1) # vlan 1999 lanpage.click_add() time.sleep(1) lanpage.input_lanIpName('1999') lanpage.input_lanIp('192.168.100.1') lanpage.input_lanNetmask('255.255.255.0') selsxjk = lanpage.selelement_byName(lanpage.selsxjk) Select(selsxjk).select_by_value('vlanid') time.sleep(1) lanpage.input_dhcpVid('1999') lanpage.click_save() time.sleep(1) #断言 list_name2 = (lanpage.getText_byXpath(lanpage.list_name2)) list_name3 = (lanpage.getText_byXpath(lanpage.list_name3)) list_ip2 = (lanpage.getText_byXpath(lanpage.list_ip2)) list_ip3 = (lanpage.getText_byXpath(lanpage.list_ip3)) list_vlanid2 = (lanpage.getText_byXpath(lanpage.list_vlanid2)) list_vlanid3 = (lanpage.getText_byXpath(lanpage.list_vlanid3)) self.assertEqual(list_name2, '1000', msg='vlan1000名称与设置的不一致') self.assertEqual(list_name3, '1999', msg='vlan1999名称与设置的不一致') self.assertEqual(list_ip2, '192.168.10.1', msg='vlan1000IP与设置的不一致') self.assertEqual(list_ip3, '192.168.100.1', msg='vlan1000IP与设置的不一致') self.assertEqual(list_vlanid2, '1000', msg='vlan1000 ID与设置的不一致') self.assertEqual(list_vlanid3, '1999', msg='vlan1000 ID与设置的不一致') #配置dhcp dhcpserver = DHCPserverpage(self.driver,self.url) #1000 dhcpserver.click_DHCPserver() time.sleep(1) dhcpserver.click_addpool() time.sleep(1) dhcpserver.input_poolName('1000') selpoolVid = dhcpserver.selelement_byName(dhcpserver.poolVid) Select(selpoolVid).select_by_value('VIF1000') time.sleep(1) dhcpserver.click_save() time.sleep(2) # 1999 dhcpserver.click_addpool() time.sleep(1) dhcpserver.input_poolName('1999') selpoolVid = dhcpserver.selelement_byName(dhcpserver.poolVid) Select(selpoolVid).select_by_value('VIF1999') time.sleep(1) dhcpserver.click_save() time.sleep(1) # 断言 list_name2 = dhcpserver.getText_byXpath(dhcpserver.list_name2) list_name3 = dhcpserver.getText_byXpath(dhcpserver.list_name3) list_int2 = dhcpserver.getText_byXpath(dhcpserver.list_int2) list_int3 = dhcpserver.getText_byXpath(dhcpserver.list_int3) self.assertEqual(list_name2, '1000', msg='pool1000名称与设置的不一致') self.assertEqual(list_name3, '1999', msg='pool1999名称与设置的不一致') self.assertEqual(list_int2, '1000', msg='pool1000IP与设置的不一致') self.assertEqual(list_int3, '1999', msg='pool1000IP与设置的不一致') # 配置网络名称 netname = netNamePage(self.driver,self.url) netname.click_wirelessExtension() time.sleep(0.5) netname.click_netName() time.sleep(1) checkOpen = str(netname.getAttribute_byId(netname.checkOpens,'checktype')) if checkOpen == '0' : # 0为关闭,1打开 time.sleep(1) netname.click_ok() # 点确认开启 time.sleep(1) checkOpen = str(netname.getAttribute_byId(netname.checkOpens, 'checktype')) self.assertEqual(checkOpen, '1', msg='无线扩展默认未关闭') # 0关闭,1打开 # 编辑默认ssid netname.click_list_edit1() time.sleep(1) netname.input_ssid('ssid_1中') netname.click_next_tab() time.sleep(1) selencryType= netname.selelement_byName(netname.encryType) Select(selencryType).select_by_value('3') # 0不加密 3 WPA-PSK/WPA2-PSK time.sleep(1) netname.input_pskPsswd('12345678') netname.click_next_tab() time.sleep(0.5) netname.input_txBand('1000') netname.input_rxBand('1000') netname.click_save() time.sleep(1) # 断言 开关打开 list_ssid1 = str(netname.getText_byXpath(netname.list_ssid1)) self.assertEqual(list_ssid1, 'ssid_1中', msg='ssid1 与设置不一致') # 新增2Gssid netname.click_add() time.sleep(1) netname.input_zoneName('2G') netname.input_ssid('2.4Gz中') netname.click_cli_5g()#默认全选,点5G=勾掉,剩下2.4G if Support == '√': # 支持vlan接口 selvlanId = netname.selelement_byName(netname.vlanId)# 选vlan接口 Select(selvlanId).select_by_value('1000') time.sleep(1) netname.click_gjxx() #点开高级选项 time.sleep(0.5) netname.click_broadcastEn() #隐藏ssid netname.click_isolateEn() #无线客户端隔离 time.sleep(0.5) netname.click_next_tab() time.sleep(1) selencryType = netname.selelement_byName(netname.encryType) Select(selencryType).select_by_value('3') # 0不加密 3 WPA-PSK/WPA2-PSK time.sleep(1) netname.input_pskPsswd('12345678') netname.click_next_tab() time.sleep(0.5) netname.input_txBand('1000') netname.input_rxBand('1000') netname.click_save() time.sleep(1) # 断言 开关打开 list_ssid2 = str(netname.getText_byXpath(netname.list_ssid2)) self.assertEqual(list_ssid2, '2.4Gz中', msg='ssid2 与设置不一致') # 新增5Gssid netname.click_add() time.sleep(1) netname.input_zoneName('5G') netname.input_ssid('5Gz中') netname.click_cli_2g() # 默认全选,点2G=勾掉,剩下5G if Support == '√': # 支持vlan接口 selvlanId = netname.selelement_byName(netname.vlanId) # 选vlan接口 Select(selvlanId).select_by_value('1999') time.sleep(1) netname.click_gjxx() # 点开高级选项 time.sleep(0.5) netname.click_broadcastEn() # 隐藏ssid netname.click_isolateEn() # 无线客户端隔离 time.sleep(0.5) netname.click_next_tab() time.sleep(1) selencryType = netname.selelement_byName(netname.encryType) Select(selencryType).select_by_value('3') # 0不加密 3 WPA-PSK/WPA2-PSK time.sleep(1) netname.input_pskPsswd('12345678') netname.click_next_tab() time.sleep(0.5) netname.click_sharelimit()#共享 netname.input_txBand('1000') netname.input_rxBand('1000') netname.click_save() time.sleep(1) # 断言 开关打开 list_ssid3 = str(netname.getText_byXpath(netname.list_ssid3)) self.assertEqual(list_ssid3, '5Gz中', msg='ssid3 与设置不一致') # 新增默认接口ssid netname.click_add() time.sleep(1) netname.input_zoneName('all') netname.input_ssid('ssid_all中') netname.click_next_tab() time.sleep(0.5) netname.click_next_tab() time.sleep(0.5) netname.click_save() time.sleep(1) # 断言 list_ssid4 = str(netname.getText_byXpath(netname.list_ssid4)) self.assertEqual(list_ssid4, 'ssid_all中', msg='ssid4 与设置不一致') self.driver.quit() logger.info('test_001_ssidNum passed')
def test_004_hairDown(self): u'''自动下发功能(重启后也能生效)''' OnlineA = getAssertText('OnlineA') netname = netNamePage(self.driver, self.url) netname.click_wirelessExtension() time.sleep(0.5) netname.click_netName() time.sleep(1) #取消掉第1个ssid的自动下发功能 list_autosend1 = str(netname.getAttribute_byXpath(netname.list_autosend1, 'checked')) if list_autosend1 == 'true': #如果ssid1 自动下发打开(性能参数和002中已经核对默认自动下发是否已打开) netname.click_list_autosend1c() time.sleep(1) list_autosend1 = str(netname.getAttribute_byXpath(netname.list_autosend1, 'checked')) self.assertEqual(list_autosend1, 'None', msg='ssid1自动下发 未取消') #勾选第四个ssid的自动下发 list_sutosend4 = str(netname.getAttribute_byXpath(netname.list_sutosend4, 'checked')) if list_sutosend4 == 'None': netname.click_list_sutosend4c() time.sleep(1) list_sutosend4 = str(netname.getAttribute_byXpath(netname.list_sutosend4, 'checked')) self.assertEqual(list_sutosend4, 'true', msg='ssid4自动下发 未开启') self.driver.quit() #1、先重启路由器 Reboot.test_reboot1(self) time.sleep(40) #刚重启好 操作AP恢复出厂 可能会引起配置未删除的问题,这里等待一下 print('重启后 稍等一下 。。。') #2、确认AP均上线 login.loginWeb(self) self.driver.implicitly_wait(10) device = deviceMgmtPage(self.driver, self.url) device.click_wirelessExtension() time.sleep(0.5) device.click_deviceMgmt() time.sleep(45) # 先确认AP均上线 x = 0 while x < 100: device.click_refreshtable() time.sleep(1) list_status1 = device.getText_byXpath(device.list_status1) list_status2 = device.getText_byXpath(device.list_status2) list_status3 = device.getText_byXpath(device.list_status3) list_status4 = device.getText_byXpath(device.list_status4) print(list_status1, list_status2, list_status3, list_status4, x) if list_status1 == OnlineA and list_status2 == OnlineA and list_status3 == OnlineA and list_status4 == OnlineA: print('4台AP均在线', x) channel1 = str(device.getAttribute_byXpath(device.list_channel1, 'data-local')) channel2 = str(device.getAttribute_byXpath(device.list_channel2, 'data-local')) channel3 = str(device.getAttribute_byXpath(device.list_channel3, 'data-local')) channel4 = str(device.getAttribute_byXpath(device.list_channel4, 'data-local')) print('channel1=', channel1, 'channel2=', channel2, 'channel3=', channel3, 'channel4=', channel4, x) if channel1 != '' and channel2 != '' and channel3 != '' and channel4 != '': print('4台AP2.4G无线接口已同步', x) break else: time.sleep(3) else: time.sleep(3) x = x + 1 else: CapPic(self.driver) logger.info(u'AP 未能同步2.4G无线接口') raise Exception('AP 未能同步2.4G无线接口') # 3、设备管理恢复AP验证自动下发功能 APmanagement.test_006_resertAP(self) logger.info('test_004_hairDown passed')