def op_web(self,total=4):
run_total = 0
while True:
run_total = run_total + 1
print 'run_total:',run_total
app_f = findwindows.find_windows(class_name_re = "MainForm")
print 'app_f:',app_f
self.driver = webdriver.Firefox()
try:
for hwnd in app_f:
win32gui.MoveWindow(hwnd,0,0,1228,664,1)
win32gui.MoveWindow(hwnd,20,20,1248,684,1)
win32gui.SetWindowPos(hwnd,win32con.HWND_TOP,0,0,1228,664,win32con.HWND_TOP|win32con.SWP_SHOWWINDOW)
break
self.driver.delete_all_cookies()
self.driver.get(self.base_url)
time.sleep(20)
js="var q=document.documentElement.scrollTop=1500"
self.driver.execute_script(js)
self.main_win = self.driver.current_window_handle
self.tmp_list=[]
num_l = self.tmp_list_num(BABY_TOTAL)
random.shuffle(num_l)
self.tmp_list.append(self.main_win)
tmpnum = 0
while True:
num = random.randrange(0,len(num_l)-1)
tmpnum = num_l[num]
del num_l[num]
print 'num:',num ,' tmpnum:',tmpnum
self.caozuo(self.driver,str(tmpnum))
self.driver.switch_to_window(self.main_win)
tmpnum = tmpnum +1
if tmpnum >total:
break
self.driver.quit()
except Exception,e:
print 'except:',e
time.sleep(60)
self.driver.quit()
pass
time.sleep(20)
new_selenium.py 文件源码
python
阅读 19
收藏 0
点赞 0
评论 0
评论列表
文章目录