演示浏览器中地址栏旁边的前进和后退功能。
具体代码:
# coding=utf-8 import time from selenium import webdriver driver = webdriver.Chrome() driver.maximize_window() driver.implicitly_wait(6) driver.get("https://www.baidu.com") time.sleep(2) elem_news=driver.find_element_by_link_text("新闻") elem_news.click() time.sleep(2) driver.back() time.sleep(2) driver.forward() time.sleep(2) driver.quit()
参考文章:https://blog.csdn.net/u011541946/article/details/69568890