def goin_default_interface(self): try: web_user_password = data.default_web_user_password() open_router_web(self,web_user_password[0]) goin_interface(self) #捕捉异常并打印异常信息 except Exception,e: print u"使用默认ip登录接口页面失败,原因如下:\n%s"%e
def goin_interface(self): try: #获取默认web页面登录的ip,用户名和密码 web_user_password = data.default_web_user_password() #登录路由 login_control.set_user(self,web_user_password[1],web_user_password[2]) login_control.submit(self) #进入接口页面 interface_control.interface_menu(self) time.sleep(5) #捕捉异常并打印异常信息 except Exception,e: print u"登录路由并进入接口页面失败,原因如下:\n%s"%e
def goin_default_dhcpdns(self): try: driver = self.driver #默认IP登录路由web页面 web_user_password = data.default_web_user_password() interface_business.open_router_web(self,web_user_password[0]) #登录路由 login_control.set_user(self,web_user_password[1],web_user_password[2]) login_control.submit(self) #进入DHCP/DNS页面 dhcpdns_control.dhcpdns_menu(self) driver.implicitly_wait(10) #捕捉异常并打印异常信息 except Exception,e: print u"使用默认ip登录DHCP/DNS页面失败,原因如下:\n%s"%e
def test(self): print '1' ip = '192.168.11.1' user = '******' password = '******' #上传tcpdump到路由器 tcpdump_control.scp_to_remote( '/home/zeng/PycharmProjects/BHU/data/BHU_tcpdump/tcpdump', ip, user, password, '/usr/sbin/') print '2' tcpdump_control.scp_to_remote( '/home/zeng/PycharmProjects/BHU/data/BHU_tcpdump/libpcap.so.1.3', ip, user, password, '/usr/lib/') print '3' #默认IP登录路由web页面 web_user_password = data.default_web_user_password() interface_business.open_router_web(self, web_user_password[0]) #登录路由 login_control.set_user(self, web_user_password[1], web_user_password[2]) login_control.submit(self) time.sleep(3) #进入门户认证,修改网关ID general_control.wifidog_menu(self) print '4' #修改门户认证的检查间隔为60s general_control.set_checkInterval(self, '60') general_control.apply(self) time.sleep(60) print '5' #ssh登录路由输入tcpdump抓包 tcpdump_control.tcpdump_command(user, ip, password, 'tcpdump -i eth1 -s0 -w /tmp/wanlog') tcpdump_control.scp_to_local(ip, user, password, '/tmp/wanlog', '/home/zeng/') f = open('/home/zeng/wanlog') log = f.read() f.close() if 'GET /index/ping/?gw_id=' in log: print 'pass' else: print 'failed'
def test(self): i = 0 while True: ping = public.get_ping('192.168.11.1') #如果能够ping通路由,则表示未失败 if ping == 0: #打开reboot.txt文件,写入pass f = open('reboot.txt', 'a') f.writelines('第%d次测试pass\n' % i) f.close() D = data.default_web_user_password() try: #打开路由页面,确认路由页面是否能显示 self.driver.get('http://%s:8088' % D[0]) time.sleep(5) self.driver.find_element_by_name('username') except: #不能显示路由页面,则登录ssh重启路由 wifidog_business.reboot(self) finally: #登录路由页面 self.driver.get('http://%s:8088' % D[0]) login_control.set_user(self, D[1], D[2]) login_control.submit(self) time.sleep(3) #进入门户认证,修改网关ID general_control.wifidog_menu(self) general_control.set_rand_gatewayId(self) general_control.apply(self) time.sleep(60) #再次重启路由 wifidog_business.reboot(self) #不能ping通则打开reboot.txt文件写入fail,退出循环 else: f = open('reboot.txt', 'a') f.writelines('第%d次测试fail\n' % i) f.closed() break i += 1
def test(self): print '1' ip ='192.168.11.1' user = '******' password = '******' #上传tcpdump到路由器 tcpdump_control.scp_to_remote('/home/zeng/PycharmProjects/BHU/data/BHU_tcpdump/tcpdump',ip,user,password,'/usr/sbin/') print '2' tcpdump_control.scp_to_remote('/home/zeng/PycharmProjects/BHU/data/BHU_tcpdump/libpcap.so.1.3',ip,user,password,'/usr/lib/') print '3' #默认IP登录路由web页面 web_user_password = data.default_web_user_password() interface_business.open_router_web(self,web_user_password[0]) #登录路由 login_control.set_user(self,web_user_password[1],web_user_password[2]) login_control.submit(self) time.sleep(3) #进入门户认证,修改网关ID general_control.wifidog_menu(self) print '4' #修改门户认证的检查间隔为60s general_control.set_checkInterval(self,'60') general_control.apply(self) time.sleep(60) print '5' #ssh登录路由输入tcpdump抓包 tcpdump_control.tcpdump_command(user,ip,password,'tcpdump -i eth1 -s0 -w /tmp/wanlog') tcpdump_control.scp_to_local(ip,user,password,'/tmp/wanlog','/home/zeng/') f = open('/home/zeng/wanlog') log = f.read() f.close() if 'GET /index/ping/?gw_id=' in log: print 'pass' else: print 'failed'