def setUp(self): logger.info('setUp start') login.loginWeb(self) self.driver.implicitly_wait(10) lanpage = NetworkConfig_LANpage(self.driver, self.url) lanpage.click_NetworkConfig() time.sleep(0.5)
def setUp(self): logger.info('setUp start') login.loginWeb(self) # admin账号登录 self.driver.implicitly_wait(10) plug = NetworkConfig_LANpage(self.driver, self.url) # 打开网络配置 - 内网配置 plug.click_NetworkConfig() time.sleep(0.5) plug.click_LANconfig() time.sleep(1) plug.click_globalconfig() time.sleep(1)
def tearDown(self): #删除 dhcpserver = DHCPserverpage(self.driver, self.url) dhcpserver.click_NetworkConfig() time.sleep(0.5) dhcpserver.click_DHCPserver() time.sleep(1) dhcpserver.click_list_delpool2() time.sleep(1) dhcpserver.click_ok() time.sleep(1) 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) self.driver.quit() logger.info('tearDown over') logger.info('%s' % ('=' * 50))
def test_001_open(self): u'''开启即插即用 错误的IP,依旧上网''' plug = NetworkConfig_LANpage(self.driver, self.url) saveSucess = getAssertText('saveSucess') #开启UPNP plug.click_upnpEN() time.sleep(0.5) plug.click_save() time.sleep(1) # 断言 开启提示信息是否有误 tips = str(plug.getText_byClass(plug.tips)) time.sleep(1) self.assertEqual(tips, saveSucess, msg='即插即用 开启出错') print('即插即用 已开启') # 判断联网 ,不能上网则报错 pingTestIP('www.163.com') # 避免失误 p = pingTestIP('www.163.com') if p == 'N': raise Exception('connect failed.') # 调用bat脚本 地址修改为 192.168.189.39 网关192.168.189.1 os.system('%s' % (batpath + 'changeStaticIP.bat')) time.sleep(5) n = 0 while n < 30: # 获取本机ip 默认有线地址,有线断开会显示无线 pcaddr = socket.gethostbyname(socket.getfqdn(socket.gethostname())) print(pcaddr, n) if str(pcaddr) != '192.168.198.39': time.sleep(2) n += 1 else: print('地址已修改为地址 192.168.198.39', n) break else: raise Exception('地址修改为192.168.198.39 失败') # 判断联网 ,不能上网则报错 pingTestIP('www.163.com') # 避免失误 p = pingTestIP('www.163.com') if p == 'N': raise Exception('connect failed.') self.driver.quit() logger.info('test_001_open passed')
def test_001_vlanInterface(self): u'''VLAN 虚接口''' vlanPortP = getParameter('vlanPortP') Support = getExcelValue(vlanPortP) lanpage = NetworkConfig_LANpage(self.driver, self.url) lanpage.click_LANconfig() time.sleep(1) lanpage.click_add() time.sleep(1) selsxjk = lanpage.selelement_byName(lanpage.selsxjk) if Support == '√': try: self.driver.implicitly_wait(2) Select(selsxjk).select_by_value('vlanid') except NoSuchElementException: CapPic(self.driver) logger.info(u'软件不支持VLAN 虚接口,与参数表不符') raise Exception(u'软件不支持VLAN 虚接口,与参数表不符') else: logger.info(u'软件支持VLAN 虚接口,与参数表相符') time.sleep(0.5) elif Support == '×': try: self.driver.implicitly_wait(2) Select(selsxjk).select_by_value('vlanid') except NoSuchElementException: logger.info(u'软件支持VLAN 虚接口,与参数表不符') else: CapPic(self.driver) logger.info(u'软件支持VLAN 虚接口,与参数表不符') raise Exception(u'软件支持VLAN 虚接口,与参数表不符') else: logger.info(u'参数表读取异常') logger.info(u'参数表读取值为:', Support) raise Exception(u'参数表读取异常') Select(selsxjk).select_by_value('default') time.sleep(0.5) self.driver.quit() logger.info('test_001_vlanInterface passed')
def test_003_WEBtimeout(self, timeout='1'): #因为字母顺序问题 该项会在最后执行 u'''修改UI超时时间''' #修改UI超时时间 accessStrategy = ManagementPolicyPage(self.driver, self.url) accessStrategy.input_sessionLife(timeout) accessStrategy.click_save() self.driver.quit() login.loginWeb(self) #任意点击一个页面,这里点击网络配置-内网配置 lanconfig = NetworkConfig_LANpage(self.driver, self.url) lanconfig.click_NetworkConfig() time.sleep(0.5) lanconfig.click_LANconfig() time.sleep(1) print('等待超时时间,在这里等待80s') time.sleep(120) #等待超时时间后,任意点击其他页面 测试超时(返回登录页面) accessStrategy = ManagementPolicyPage(self.driver, self.url) accessStrategy.click_sysConfig() time.sleep(0.5) accessStrategy.click_ManagementPolicy() time.sleep(2) url = self.driver.current_url if '/login.html' not in url: CapPic(self.driver) logger.info(u"未跳回登录页面") raise Exception('未跳回登录页面') self.driver.quit() # 将超时时间改回默认值 login.loginWeb(self) # admin账号登录 self.driver.implicitly_wait(10) accessStrategy = ManagementPolicyPage(self.driver, self.url) # 进入系统配置-网管策略-网管访问策略 accessStrategy.click_sysConfig() time.sleep(0.5) accessStrategy.click_ManagementPolicy() time.sleep(1) accessStrategy.click_AccessPolicy() time.sleep(1) accessStrategy.input_sessionLife('10') accessStrategy.click_save() self.driver.quit() logger.info('test_003_WEBtimeout passed')
def test_002_DNSProxy(self): u'''DNS Proxy代理、酒店即插即用''' dhcpserver = DHCPserverpage(self.driver, self.url) dhcpserver.click_NetworkConfig() time.sleep(0.5) dhcpserver.click_DHCPserver() time.sleep(1) dhcpserver.click_GlobalConfig() time.sleep(1) switch = str( dhcpserver.getAttribute_byXpath(dhcpserver.dnspEns, 'checked')) self.assertEqual(switch, 'true', msg='dns代理 默认未开启') # 酒店即插即用 lanpage = NetworkConfig_LANpage(self.driver, self.url) lanpage.click_LANconfig() time.sleep(1) lanpage.click_globalconfig() time.sleep(1) switch2 = str( lanpage.getAttribute_byXpath(lanpage.upnpCloseS, 'checked')) self.assertEqual(switch2, 'true', msg='UPNP 默认开启') print('DNS Proxy代理、酒店即插即用 验证通过') # 静态路由 routeconfig = RouteConfigPage(self.driver, self.url) routeconfig.click_Routeconfig() time.sleep(1) routeconfig.click_add() time.sleep(1) routeconfig.click_modalhide() time.sleep(0.5) # #策略路由 # routeconfig.click_PolicyRoute() # time.sleep(1) # routeconfig.click_addPolicy() # time.sleep(1) # routeconfig.click_modalhide() # time.sleep(0.5) self.driver.quit() logger.info('test_002_DNSProxy 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_wifi2(self): u'''2.4G无线加密、限速、无线vlan''' #lan lanpage = NetworkConfig_LANpage(self.driver, self.url) lanpage.click_NetworkConfig() time.sleep(0.5) lanpage.click_LANconfig() time.sleep(1) lanpage.click_add() lanpage.input_lanIpName('wifi1') lanpage.input_lanIp('213.1.10.1') selsxjk = lanpage.selelement_byName(lanpage.selsxjk) Select(selsxjk).select_by_value('wifi') lanpage.click_wifiInter1() lanpage.click_save() time.sleep(2) list_name2 = (lanpage.getText_byXpath(lanpage.list_name2)) list_ip2 = (lanpage.getText_byXpath(lanpage.list_ip2)) self.assertEqual(list_name2, 'wifi1', msg='wifi1名称与设置的不一致') self.assertEqual(list_ip2, '213.1.10.1', msg='wifi1 IP与设置的不一致') # dhcp dhcpserver = DHCPserverpage(self.driver, self.url) dhcpserver.click_DHCPserver() time.sleep(1) dhcpserver.click_addpool() time.sleep(1) dhcpserver.input_poolName('wifi1') selpoolVid = dhcpserver.selelement_byName(dhcpserver.poolVid) Select(selpoolVid).select_by_value('wifi1') time.sleep(1) dhcpserver.click_save() time.sleep(2) list_name2 = dhcpserver.getText_byXpath(dhcpserver.list_name2) list_int2 = dhcpserver.getText_byXpath(dhcpserver.list_int2) self.assertEqual(list_name2, 'wifi1', msg='wifi1名称与设置的不一致') self.assertEqual(list_int2, 'wifi1', msg='wifi1 IP与设置的不一致') wifi = BasicConfigPage(self.driver, self.url) wifi.click_wifiConfig() time.sleep(0.5) wifi.click_BasicConfig() time.sleep(1) wifi.click_list_edit1() time.sleep(1) wifi.input_ssid1('test3_2.41') ifName = wifi.selelement_byName(wifi.ifName) Select(ifName).select_by_value('wifi1') wifi.click_securitySet() time.sleep(1) secMode1 = wifi.selelement_byName(wifi.secMode1) Select(secMode1).select_by_value('WPAPSK') time.sleep(0.5) wifi.input_pskPsswd1('123456789') wifi.click_Bandwidthset() time.sleep(1) wifi.input_txBand1('1000') wifi.input_rxBand1('1000') wifi.click_save() time.sleep(1) lsit_ssid1 = wifi.getText_byXpath(wifi.list_ssid1) self.assertEqual(lsit_ssid1, 'test3_2.41', msg='2.4G SSID保存异常') list_wifiInter1 = wifi.getText_byXpath(wifi.list_wifiInter1) self.assertEqual(list_wifiInter1, 'wifi1', msg='2.4G wifi接口保存异常') list_speed1 = wifi.getText_byXpath(wifi.list_speed1) self.assertEqual(list_speed1, '1000/1000', msg='2.4G SSID保存异常') list_wifipwd1 = wifi.getAttribute_byXpath(wifi.list_wifipwd1, 'data-local') self.assertEqual(list_wifipwd1, '123456789', msg='2.4G密码保存异常') time.sleep(13) tn = telnetlib.Telnet(host=host, port=port) #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.41" in result: print('2.4G SSID配置正常') else: raise Exception('2.4G SSID配置异常') if "WPAPSK1=123456789" in result: print('2.4G 密码配置正常') else: raise Exception('2.4G 密码配置异常') elif cpumodel == "Qualcomm": if "ssid=test3_2.41" in result: print('2.4G SSID配置正常') else: raise Exception('2.4G SSID配置异常') if "key=123456789" in result: print('2.4G 密码配置正常') else: raise Exception('2.4G 密码配置异常') tn.close() # tn.write('exit\n') logger.info('test_001_wifi2 passed')
def test_002_portRateLAN(self): u'''lan默认协商速率及端口速率修改''' # 进入-系统监控-系统状态 获取型号判断是否支持千M sysmonitor = sysStaticPage(self.driver, self.url) sysmonitor.click_systemWatch() time.sleep(0.5) sysmonitor.click_sysStatic() time.sleep(1) Model = str(sysmonitor.getText_byXpath(sysmonitor.Model)) print(Model) # 协商速率LAN口 lanpage = NetworkConfig_LANpage(self.driver, self.url) lanpage.click_NetworkConfig() time.sleep(0.5) lanpage.click_LANconfig() time.sleep(1) lanpage.click_globalconfig() time.sleep(1) LanMode_seled1 = lanpage.getAttribute_byXpath(lanpage.lanRateseled, 'value') self.assertEqual(str(LanMode_seled1), '3', msg='LAN默认端口速率不为自动协商') LanMode_seled2 = lanpage.getAttribute_byXpath(lanpage.lanRateseled, 'selected') self.assertEqual(str(LanMode_seled2), 'true', msg='LAN默认端口速率不为自动协商') LanMode = lanpage.selelement_byXpath(lanpage.sellanRate) time.sleep(1) # 0-10M全双工 1-100M全双工 2-1000M全双工 3-自动 4-10M半双工 5-100M半双工 Select(LanMode).select_by_value('0') time.sleep(1) Select(LanMode).select_by_value('1') Select(LanMode).select_by_value('3') Select(LanMode).select_by_value('4') Select(LanMode).select_by_value('5') if 'G' in str(Model) or 'g' in str(Model): try: Select(LanMode).select_by_value('2') except NoSuchElementException: raise Exception('LAN口不支持千M协商速率') self.driver.quit() logger.info('test_002_portRateLAN passed')
def test_004_changeMAC(self): u'''MAC地址修改''' CannotbeblankA = getAssertText('CannotbeblankA') lanpage = NetworkConfig_LANpage(self.driver, self.url) lanpage.click_NetworkConfig() time.sleep(0.5) lanpage.click_LANconfig() time.sleep(1) lanpage.click_globalconfig() time.sleep(1) # lan口MAC 清空lan mac的值保存 确认是否可以修改 lanpage.clear_mac() time.sleep(0.5) lanpage.click_save() time.sleep(0.5) lan_tips = str(lanpage.getText_byXpath(lanpage.lan_tips)) self.assertIn(CannotbeblankA, lan_tips, msg='lan口mac地址清空保存提示错误') print('lan口mac地址更改 验证通过') # wan1口MAC 清空lan mac的值保存 确认是否可以修改 wanpage = NetworkConfig_wanpage(self.driver, self.url) wanpage.click_WANconfig() time.sleep(1) wanpage.click_line1edit() time.sleep(1) connectionType = wanpage.selelement_byName(wanpage.connectionType) Select(connectionType).select_by_value('DHCP') time.sleep(0.5) wanpage.clear_line1editmac() time.sleep(0.5) wanpage.click_save() time.sleep(0.5) wan_tips = str(wanpage.getText_byXpath(wanpage.wan_tips)) self.assertIn(CannotbeblankA, lan_tips, msg='wan口mac地址清空保存提示错误') print('wan口mac地址更改 验证通过') self.driver.quit() logger.info('test_004_changeMAC passed')
def test_003_LanMultiIP(self): u'''Lan口多IP''' reachMax3A = getAssertText('reachMax3A') User = getweb('User') Passwd = getweb('Passwd') lanpage = NetworkConfig_LANpage(self.driver, self.url) lanpage.click_NetworkConfig() time.sleep(0.5) lanpage.click_LANconfig() time.sleep(1) # 新增lan口 num = 1 while num < 5: num += 1 lanpage.click_add() time.sleep(1) lanpage.input_lanIpName('lan%s' % num) lanpage.input_lanIp('213.18.%s.1' % num) lanpage.click_save() if num < 5: time.sleep(5) i = 0 while i < 10: now_url = str(self.driver.current_url) if '/noAuth/login.html' not in now_url: time.sleep(2) else: break i += 1 print(now_url, i) self.driver.quit() login.loginWeb(self) self.driver.implicitly_wait(10) loginPage = LoginPage(self.driver, self.url) lanpage = NetworkConfig_LANpage(self.driver, self.url) lanpage.click_NetworkConfig() time.sleep(0.5) lanpage.click_LANconfig() time.sleep(1) elif num >= 5: time.sleep(1) tips = (lanpage.getText_byClass(lanpage.tipsshowin)) self.assertIn(reachMax3A, tips, msg='提示信息有误') print('lan口数量最大为4 验证通过') time.sleep(1) lanpage.click_modalhide() time.sleep(0.5) lanpage.click_allsel() time.sleep(0.2) lanpage.click_delete() time.sleep(1) lanpage.click_ok() time.sleep(15) #删除接口要等等 self.driver.quit() logger.info('test_003_LanMultiIP passed')
def test_002_close(self): u'''关闭即插即用 错误的IP,无法上网''' plug = NetworkConfig_LANpage(self.driver, self.url) saveSucess = getAssertText('saveSucess') # 关闭UPNP plug.click_upnpClose() time.sleep(0.5) plug.click_save() time.sleep(1) # 断言 开启提示信息是否有误 tips = str(plug.getText_byClass(plug.tips)) time.sleep(1) self.assertEqual(tips, saveSucess, msg='即插即用 开启出错') print('即插即用 已关闭') #判断联网 ,关闭即插即用后 错误IP用户应该不能上网 pcaddr = socket.gethostbyname(socket.getfqdn(socket.gethostname())) if pcaddr != '192.168.189.39': # 调用bat脚本 地址修改为 192.168.189.39 网关192.168.198.1 os.system('%s' % (batpath + 'changeStaticIP.bat')) time.sleep(5) n = 0 while n < 30: # 获取本机ip 默认有线地址,有线断开会显示无线 pcaddr = socket.gethostbyname( socket.getfqdn(socket.gethostname())) print(pcaddr, n) if str(pcaddr) != '192.168.198.39': time.sleep(2) n += 1 else: print('地址已修改为地址 192.168.198.39', n) break else: raise Exception('地址修改为192.168.198.39 失败') time.sleep(3) pingTestIP('114.114.114.114') #避免失误 pingTestIP() #避免失误 p = pingTestIP('114.114.114.114') if p == 'Y': raise Exception('错误IP用户依旧可以上网') p = pingTestIP() if p == 'Y': raise Exception('错误IP用户依旧可以访问路由器') time.sleep(1) #将IP改回自动获取 os.system('%s' % batpath + 'changeDhcpIp.bat') time.sleep(5) n = 0 while n < 30: # 获取本机ip 默认有线地址,有线断开会显示无线 pcaddr1 = socket.gethostbyname(socket.getfqdn( socket.gethostname())) print(pcaddr1, n) if '192.168.' not in str(pcaddr1): time.sleep(2) n += 1 else: print('IP地址已自动获取成功', n) break else: raise Exception('未获取到地址') # 判断联网 ,不能上网则报错 pingTestIP('www.163.com') # 避免失误 p = pingTestIP('www.163.com') if p == 'N': raise Exception('connect failed.') self.driver.quit() logger.info('test_002_close passed')
def tearDown(self): #修改lan口为自动模式,谨防lan口速率出问题 太卡 login.loginWeb(self) # admin账号登录 self.driver.implicitly_wait(10) lanpage = NetworkConfig_LANpage(self.driver, self.url) lanpage.click_NetworkConfig() time.sleep(0.5) lanpage.click_LANconfig() time.sleep(1) lanpage.click_globalconfig() time.sleep(1) lanmodenow = lanpage.getAttribute_byXpath(lanpage.lanmodenow, 'selected') print(lanmodenow) if lanmodenow != 'true': LanMode = lanpage.selelement_byXpath(lanpage.sellanRate) Select(LanMode).select_by_value('3') time.sleep(0.5) lanpage.click_save() time.sleep(10) n = 0 while n < 20: ping = pingTestIP() if ping != 'Y': time.sleep(1) n += 1 else: break self.driver.quit() logger.info('tearDown over') logger.info('%s' % ('=' * 50))
def test_002_changeRateLAN(self): u'''lan1端口协商速率修改 ''' # # 进入-系统监控-系统状态 获取型号判断是否支持千M # sysmonitor = sysStaticPage(self.driver, self.url) # sysmonitor.click_systemWatch() # time.sleep(0.5) # sysmonitor.click_sysStatic() # time.sleep(1) # Model = str(sysmonitor.getText_byXpath(sysmonitor.Model)) # print(Model) #Lan口速率修改 lanpage = NetworkConfig_LANpage(self.driver, self.url) lanpage.click_NetworkConfig() time.sleep(0.5) lanpage.click_LANconfig() time.sleep(1) lanpage.click_globalconfig() time.sleep(1) LanMode = lanpage.selelement_byXpath(lanpage.sellanRate) # 0-10M全双工 1-100M全双工 2-1000M全双工 3-自动 4-10M半双工 5-100M半双工 #改为10M try: Select(LanMode).select_by_value('0') time.sleep(0.5) except ElementNotVisibleException: CapPic(self.driver) logger.info(u'lan口不支持修改为10M全双工') raise Exception(u'lan口不支持修改为10M全双工') lanpage.click_save() time.sleep(10) n = 0 while n < 20: ping = pingTestIP() if ping != 'Y': time.sleep(1) n += 1 else: break self.driver.quit() i = 0 while i < 30: swRate = swconfig.test_getLANSpeed(self) print(swRate) if swRate != 'speed10M': time.sleep(1) i += 1 else: break else: logger.info(u'交换机端口速率为: %s' % swRate) logger.info(u'交换机协商速率 不为10M') raise Exception(u'交换机协商速率 不为10M') # 改为100M login.loginWeb(self) # admin账号登录 self.driver.implicitly_wait(10) time.sleep(2) #谨防10M页面卡住 lanpage = NetworkConfig_LANpage(self.driver, self.url) lanpage.click_NetworkConfig() time.sleep(0.5) lanpage.click_LANconfig() time.sleep(1) lanpage.click_globalconfig() time.sleep(1) LanMode = lanpage.selelement_byXpath(lanpage.sellanRate) Select(LanMode).select_by_value('1') time.sleep(0.5) lanpage.click_save() time.sleep(10) n = 0 while n < 20: ping = pingTestIP() if ping != 'Y': time.sleep(1) n += 1 else: break self.driver.quit() i = 0 while i < 30: swRate = swconfig.test_getLANSpeed(self) print(swRate) if swRate != 'speed100M': time.sleep(1) i += 1 else: break else: logger.info(u'交换机端口速率为: %s' % swRate) logger.info(u'交换机协商速率 不为100M') raise Exception(u'交换机协商速率 不为100M') # 改为1000M support = getExcelValue(portTateLANp) # print('support:',support) if '千' in str(support): login.loginWeb(self) # admin账号登录 self.driver.implicitly_wait(10) lanpage = NetworkConfig_LANpage(self.driver, self.url) lanpage.click_NetworkConfig() time.sleep(0.5) lanpage.click_LANconfig() time.sleep(1) lanpage.click_globalconfig() time.sleep(1) LanMode = lanpage.selelement_byXpath(lanpage.sellanRate) try: Select(LanMode).select_by_value('2') time.sleep(0.5) lanpage.click_save() time.sleep(10) n = 0 while n < 20: ping = pingTestIP() if ping != 'Y': time.sleep(1) n += 1 else: break self.driver.quit() i = 0 while i < 30: swRate = swconfig.test_getWAN1Speed(self) print(swRate) if swRate != 'speed1000M': time.sleep(1) i += 1 else: break else: logger.info(u'交换机端口速率为: %s' % swRate) logger.info(u'交换机协商速率 不为1000M') raise Exception(u'交换机协商速率 不为1000M') except NoSuchElementException: raise Exception('WAN口不支持千M协商速率') # 改为auto login.loginWeb(self) self.driver.implicitly_wait(10) lanpage = NetworkConfig_LANpage(self.driver, self.url) lanpage.click_NetworkConfig() time.sleep(0.5) lanpage.click_LANconfig() time.sleep(1) lanpage.click_globalconfig() time.sleep(1) LanMode = lanpage.selelement_byXpath(lanpage.sellanRate) Select(LanMode).select_by_value('3') time.sleep(0.5) lanpage.click_save() time.sleep(10) n = 0 while n < 20: ping = pingTestIP() if ping != 'Y': time.sleep(1) n += 1 else: break self.driver.quit() swRate = swconfig.test_getWAN1Speed(self) print(swRate) if '千' in str(support): i = 0 while i < 30: swRate = swconfig.test_getWAN1Speed(self) print(swRate) if swRate != 'speed1000M': time.sleep(1) i += 1 else: break else: logger.info(u'交换机端口速率为: %s' % swRate) logger.info(u'交换机协商速率 不为1000M') raise Exception(u'交换机协商速率 不为1000M') else: i = 0 while i < 30: swRate = swconfig.test_getLANSpeed(self) print(swRate) if swRate != 'speed100M': time.sleep(1) i += 1 else: break else: logger.info(u'交换机端口速率为: %s' % swRate) logger.info(u'交换机协商速率 不为100M') raise Exception(u'交换机协商速率 不为100M') logger.info('test_002_changePortRateLAN 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')