1 # coding:utf-8 2 from time import sleep 3 from selenium import webdriver 4 5 #Create Google browser object 6 b = webdriver.Chrome() 7 #Set browser size 8 b.set_window_size(800, 1000 ) 9 #Browser maximize 10 b.maximize_window() 11 #Set the global waiting time (invisible waiting time) 12 b.implicitly_wait(10 ) 13 #Open the specified url 14 b.get ( ' http://www.baidu.com ' ) 15 #Back operation of browser navigation bar 16 b.back() 17 #Forward operation of browser navigation bar 18 b.forward() 19 #Print browser current window size 20 print b.get_window_size() 21 #Get The coordinates of the current browser (X, Y axis) 22 print b.get_window_position() 23 #Browser navigation bar refresh operation 24 b.refresh() 25 #Print the current page source code 26 print b.page_source 27 #Print the current page URL 28 print b.current_url 29 #Sleep for 3 seconds 30sleep(3 ) 31 #Close the current window 32 b.close() 33 #Close the browser 34 b.quit()