Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to realize screenshot by Appium

Shulou Source: shulou.com Published: 2022-06-02 02:59:02 11月23日 Update

This article mainly introduces how to achieve the screenshot of Appium, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand.

Appium screenshot method

Appium screenshot is essentially the screenshot mechanism of Selenium. Because Appium is based on Selenium.

The method is implemented as follows (when you use it, you can directly call the screenShot method and pass in the file path.) :

Public static void screenShot (AndroidDriver driver,String sFilePath) {File file=new File (sFilePath); / / delete try {if (file.exists ()) {file.delete () if the screenshot exists. }} catch (Exception e) {e.printStackTrace ();} / / screenshot File newFile=driver.getScreenshotAs (OutputType.FILE); try {FileUtils.copyFile (newFile, file) } catch (IOException e) {e.printStackTrace ();}}

For example: screenShot (driver, "c:\\ cheersTest\\ screenshots\\ test1.png")

Thank you for reading this article carefully. I hope the article "how to achieve screenshots in Appium" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Screenshots articles methods values interests at the same time documents time more friends essence mechanism knowledge editing industry information information channels paths or channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Xiaomi Shulou Tech Info MySQL Microsoft