Python+Selenium基础篇之12-自定义浏览器窗口大小

设置符合不同测试场景浏览器窗口大小
测试脚本代码如下:

# coding=utf-8
import time
from selenium import webdriver

driver = webdriver.Chrome()
driver.maximize_window()  # 全屏
driver.get('https://www.baidu.com')
time.sleep(1)
print(driver.get_window_size())

driver.set_window_size(1280, 800)  # 分辨率 1280*800
time.sleep(1)
print(driver.get_window_size())

driver.set_window_size(1024, 768)  # 分辨率 1024*768
time.sleep(1)
print(driver.get_window_size())

driver.quit()

你可能感兴趣的:(Python,+,Selenium从基础到高级篇,测试工具,python,selenium)