使用屏幕截图方法 driver.getScreenshotAs(OutputType.FILE) 提示 Connection reset,是端口占用问题吗

【测试代码】
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.WebElement;
import io.appium.java_client.android.AndroidDriver;

public class Test{
public static void screenshot(AndroidDriver driver){
try {
File screenShot = driver.getScreenshotAs(OutputType.FILE); //此段停止执行,提示 Connection reset
FileUtils.copyFile(screenShot,new File("./dir"+getDatetime()+".jpg"));

} catch (Exception e) {
e.printStackTrace(); }
}

【系统输出】提示 1
2017-02-25 06:35:50,685 [main] INFO com.tms.app.itms.Log - 开始截图。。。
2017-02-24 21:01:56,248 [Forwarding screenshot on session 9eb17cda-76dc-4399-bc8e-7a3daa4fb690 to remote] INFO
org.apache.http.impl.execchain.RetryExec - I/O exception (java.net.SocketException) caught when processing request to {}->http://127.0.0.1:4723: Connection reset
2017-02-24 21:01:56,248 [Forwarding screenshot on session 9eb17cda-76dc-4399-bc8e-7a3daa4fb690 to remote] INFO

org.apache.http.impl.execchain.RetryExec - Retrying request to {}->http://127.0.0.1:4723

【服务端信息】

info: JSONWP Proxy: Got response with status 200: {"sessionId":"023b3d5143cd0aefeff82a34a0d7e65d","status":0,"value":null}
info: JSONWP Proxy: Replacing sessionId 023b3d5143cd0aefeff82a34a0d7e65d with 2e6fc0d3-78de-46b1-885e-f3f816938650
info: <-- POST /wd/hub/session/2e6fc0d3-78de-46b1-885e-f3f816938650/element/0.3481348926958947-1/value 200 331.625 ms - 76
info: --> GET /wd/hub/session/2e6fc0d3-78de-46b1-885e-f3f816938650/screenshot {}
info: JSONWP Proxy: Proxying [GET /wd/hub/session/2e6fc0d3-78de-46b1-885e-f3f816938650/screenshot] to [GET http://127.0.0.1:9515/wd/hub/session/023b3d5143cd0aefeff82a34a0d7e65d/screenshot] with body: {}
info: [debug] Didn't get a new command in 60 secs, shutting down...
info: Shutting down appium session


↙↙↙阅读原文可查看相关链接,并与作者交流