場景
這兩個功能一般不太常用。所能想到的場景大概也就是在幾個頁面間來回跳轉,省去每次都get url。
代碼
#!/usr/bin/env python # -*- coding:utf-8 -*- ''' Created on 2018/5/9 11:26 @author: Jeff Lee @file: 前進和后退.py ''' from selenium import webdriver import time print('打開瀏覽器') cl = webdriver.Firefox() time.sleep(2) print('打開第一個網頁') first_utl = 'http://127.0.0.1:8000' cl.get(first_utl) time.sleep(2) print('打開第二個網頁') second_utl = 'http://58.251.136.209:19001/uniquefu/52.html' cl.get(second_utl) time.sleep(2) print('后退網頁') cl.back() time.sleep(2) print('前進網頁') cl.forward() time.sleep(2) print('關閉瀏覽器') cl.quit()
參考 http://www.cnblogs.com/nbkhic/tag/%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95/