如何使用Appium(最好是python)拍摄本地iOS屏幕截图,并在设备/模拟器相册中自动查看它们?

2024-03-28 15:53:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试自动截图和上传通过相册在iOS模拟器。如果我们使用Appium save_屏幕截图(output),那么我们不知道相册的路径,或者没有明确写入相册的权限。相反,我们被迫将屏幕截图保存到计算机/项目中的某个路径。在

我试过这两种:

  1. 屏幕截图base64=self.driver.get_截图()
  2. 文件=((TakesScreen)自驱动程序).getScreenshotAs获取屏幕截图(OutputType.FILE文件)

一。在

screenshotBase64 = self.driver.get_screenshot_as_base64()

file  = ((TakesScreenshot)self.driver).getScreenshotAs(OutputType.FILE);

期望:截图并保存到相册中 实际情况:什么都没发生


Tags: 文件self路径outputget屏幕savedriver
2条回答

您可以使用驱动程序将屏幕截图保存为文件:

self.wd = webdriver.Remote('http://localhost:{0}/wd/hub'.format(self.port), self.desired_caps)
self.wd.get_screenshot_as_file('{0}.jpg'.format(self.desired_caps['deviceName']))

没有单独的命令,您必须使用以下组合:

  1. Screenshot-将屏幕截图作为Base64字符串
  2. Push File-在iOS设备上保存屏幕截图

比如:

screenshotBase64 = self.driver.get_screenshot_as_base64()
driver.push_file('/path/to/device/foo.bar', screenshotBase64)

您可能还对填补Appium空白的SeeTest - Appium Extension命令感兴趣

相关问题 更多 >