标签:https screens file coding utf-8 www window 最大化 bsp
selenium对web的ui页面进行测试
操作浏览器
#!/usr/bin/env python
#-*- coding:utf-8 -*-
from selenium import webdriver
import time
#打开浏览器
driver =webdriver.Firefox()
#driver =webdriver.Ie()
#driver =webdriver.Chrome()
url1= "http://ps.gongfudou.com/admin/dashboard"
url2="https://www.baidu.com"
driver.get(url1)
#设置休眠时间3秒
time.sleep(3)
#刷新页面
driver.refresh()
driver.get(url2)
time.sleep(3)
driver.back() #返回上一页
time.sleep(3)
driver.forward #切换下一页
driver.set_window_size(540,960) #设置窗口大小
time.sleep(2)
driver.maximize_window() #最大化
driver.get_screenshot_as_file(‘/Users/gongfudou/Downloads/图片/1.jpg‘) #截图
#driver.close()
driver.quit()
标签:https screens file coding utf-8 www window 最大化 bsp
原文地址:https://www.cnblogs.com/jianjian12138/p/9771093.html