练习场景:在百度首页,利用快捷键Ctrl+A全选
具体代码:
# coding=utf-8 from selenium import webdriver from selenium.webdriver.common.keys import Keys import time driver = webdriver.Chrome() driver.maximize_window() driver.get('https://www.baidu.com/') driver.find_element_by_tag_name('body').click() driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL+'a') print('页面已全选。')
参考文章:https://blog.csdn.net/u011541946/article/details/70036864