Python selenium-webdriver Common browser operation (10)

Source: Internet
Author: User

Some of the methods and properties commonly used by browsers are actually quite simple, but they are often employed in the actual testing process.

    • Load URL in Browser
method: Get (URL) instance: Driver.get ("http//:www.baidu.com")
    • Maximize browser window
Method: Maximize_window () instance: Driver.maximize_window ()
    • Forward
Method: Forward () instance: Driver.forward ()
    • Back off
Method: Back () instance: Driver.back ()
    • Refresh
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 ()
    • Search by cookie Name
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")
    • Add cookies
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 ()
    • Close the current window
Method: Close () instance: Driver.close ()

Python selenium-webdriver Common browser operation (10)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.