Some of the methods and properties commonly used by browsers are actually quite simple, but they are often employed in the actual testing process.
method: Get (URL) instance: Driver.get ("http//:www.baidu.com")
Method: Maximize_window () instance: Driver.maximize_window ()
Method: Forward () instance: Driver.forward ()
Method: Back () instance: Driver.back ()
Method: Refresh () instance: Driver.refresh ()
- Gets the URL of the current page
Method: Current_url Instance: Driver.current_url
- Gets the title of the current page
Method: Title instance: Driver.title
- Gets the current page HTML source code
Method: Page_source Instance: Driver.page_source
- Get all cookie information for the current session
Method: Get_cookies () instance: Driver.get_cookies ()
method: Get_cookie (Cookie_name) instance: Driver.get_cookie (name= ' key-value ') #获取name = 'key-value' The cookie value
- Delete Browser so the cookies
Method: Delete_all_cookies () instance: Driver.delete_all_cookies ()
- Delete a specified cookie
method: Delete_cookie (name) instance: Deriver.delete_cookie ("my_cookie")
method: Add_cookie (cookie_dict) instance: Driver.add_cookie ({'name':' Xiaoqiang'# Note that what is needed here is a dictionary
- Gets the current window's
Method: Save_screenshot ( ' image storage Path/image name ') instance: Driver.save_screenshot (' Bing.png')
- Exit the driver and close all windows
Method: Quit () instance: Driver.quit ()
Method: Close () instance: Driver.close ()
Python selenium-webdriver Common browser operation (10)