控制浏览器操作

最后更新于:2022-04-02 03:42:29

[TOC] ## 控制浏览器窗口大小 ``` driver.get("http://m.baidu.com") driver.set_window_size(480, 800) ``` ## 控制浏览器后退、前进 ``` import time from selenium import webdriver if __name__ == '__main__': driver = webdriver.Chrome() driver.get('https://www.baidu.com') driver.find_element_by_css_selector("#kw").send_keys("hello word") driver.find_element_by_css_selector("#su").click() time.sleep(2) driver.back() time.sleep(2) driver.quit() ```
';