简体   繁体   中英

How to take Native iOS Screenshots using Appium (preferably python) and see them in device/simulator Photo album automatically?

I am trying to automate taking screenshot and uploading via photo album in iOS Simulator. If we use Appium save_screenshot(output), we don't know the photo album path or don't have permissions to write explicitly in to the Photo Album. Instead we are forced to save the screen shot to a path in our computer/project.

I have tried these two:

  1. screenshotBase64 = self.driver.get_screenshot_as_base64()
  2. file = ((TakesScreenshot)self.driver).getScreenshotAs(OutputType.FILE);

.

screenshotBase64 = self.driver.get_screenshot_as_base64()

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

Expected: Screenshot taken and saved into the photo Album Actual: Nothing happens

There is no single command for this, you will have to go for the following combination:

  1. Screenshot - take a screenshot as Base64 string
  2. Push File - save the screenshot on the iOS device

Like:

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

You might also be interested in SeeTest - Appium Extension commands which fill Appium's gaps

You could use the driver to save the screenshot as a file:

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']))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM