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