Python + Appium Get the current screen screenshot method of encapsulation

Source: Internet
Author: User
Tags appium

How to use:get_screenshot_as_file (filename), from selenium\webdriver\remote\webdiver.py

def take_screenshot (self,name ="Takeshot"):        " method explain: Gets the parameter explain of the current screen: the name of the" name "Usage:device.take_screenShot ( U "Profile") #实际保存的结果为: 2018-01-13_17_10_58_ personal homepage. png "Day = Time.strftime ("%y-%m-%d", Time.localtime (Time.time ())) Fq=".. \\screenShots\\"+Day #fq =os.getcwd () [: -4] + ' screenshots\\ ' +Day is  based on the obtained path, and then the Intercept path is saved to the directory where you want to store the TM= Time.strftime ("%y-%m-%d_%h_%m_%s", Time.localtime (Time.time ())) type='. PNG'filename=""        ifos.path.exists (FQ): filename= fq+"\\"+tm+"_"+name+typeElse: Os.makedirs (FQ) filename= fq+"\\"+tm+"_"+name+type#C          = OS.GETCWD () #R "\ \". Join (C.split ("\ \")  ) #此2行注销实现的功能为将路径中的 \ Replace with \ \ self.driver.get_screenshot_as_file (filename)

Note the point:

1, given the name of Chinese, you need to add u, such as:device.take_screenshot (U "homepage"), otherwise save the file name is disorderly;

2, if the given name is in English, you do not need to add u

Python + Appium to get the current screen method of encapsulation

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.