设置不同测试场合浏览器窗口大小。
具体代码:
# 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) time.sleep(1) print(driver.get_window_size()) driver.set_window_size(1024,768) time.sleep(1) print(driver.get_window_size())
参考文章:https://blog.csdn.net/u011541946/article/details/69681153