gpt4 book ai didi

java - Appium 在截屏时崩溃了

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:54:06 25 4
gpt4 key购买 nike

失败时无法截图。早些时候,在我的真实 iOS 设备上一切正常,但现在 - Appium 崩溃并且无法截取屏幕截图,我无法弄清楚发生了什么。

Appium 日志:link here

Java代码:

public void takeScreenShotOnFailure(ITestResult testResult, String name) throws IOException  {
if (testResult.getStatus() == ITestResult.FAILURE) {
File scrFile = dr.getScreenshotAs(OutputType.FILE);
Date date = new Date();
SimpleDateFormat home = new SimpleDateFormat("dd.MM hh:mm:ss");
String homedate = home.format(date);
FileUtils.copyFile(scrFile, new File("test-output/screenshots/" + name + ".jpg"));
}
}

有什么想法吗?

最佳答案

试试这段代码:

  WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com/");
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
// Now you can do whatever you need to do with it, for example copy somewhere
FileUtils.copyFile(scrFile, new File("c:\\tmp\\screenshot.png"));

关于java - Appium 在截屏时崩溃了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36738115/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com