selenium调用火狐浏览器
#! /usr/bin/env python3
from selenium import webdriver
import time
browser = webdriver.Firefox()
#browser.set_window_size(1000,3000)
browser.get('https://www.toutiao.com/i6485137145940935181/')
time.sleep(2)
for num in range(1,10):
try:
browser.refresh() # 刷新方法 refresh
time.sleep(1)
browser.execute_script("window.scrollTo(0, 500);")
time.sleep(1)
browser.execute_script("window.scrollTo(0, 1000);")
time.sleep(1)
browser.execute_script("window.scrollTo(0, 1500);")
time.sleep(2)
print ('test pass: refresh successful')
except Exception as e:
print ("Exception found", format(e))
browser.quit()