同一个 testcase 执行 100 次,执行到 71 次报这个错误,以下是 appium 日志
自动化脚本
/**
* 打印异常信息
* @param typeName
* @param count
* @param e
* @return
*/
private int printExceptionLog(String typeName, Exception e) {
int type = 0;
String className = e.getClass().getName();
if ("org.openqa.selenium.NoSuchElementException".equals(className)) {
log.info(typeName + ":元素未找到");
} else if ("org.openqa.selenium.remote.SessionNotFoundException".equals(className)) {
type = 1;
log.info(className + ":目标应用程序似乎死亡");
} else if ("java.lang.AssertionError".equals(className)) {
log.info(className + ":断言失败");
} else {
log.info(className + ":未知");
}
return type;
}
/**
* 100次语音通话,每次通话时长5s
*/
@Test(enabled = true, invocationCount = 100)
public void voiceCallBy100TimesTest() {
int count = ++sum;
try {
if (count == 1) log.info("100次语音通话,每次通话时长5s");
log.info("第" + count + "次语音通话");
pageA.telephoneButton.click();
//log.info("A呼叫B");
Thread.sleep(1000);
pageB = new Page(B);
pageB.voiceWaitCallRight.click();
//log.info("B接通电话");
Thread.sleep(5000);
pageA = new Page(A);
pageA.voiceCallHangOn.click();
//log.info("A挂断");
Thread.sleep(2000);
} catch (Exception e) {
int type = this.printExceptionLog("第" + count + "次语音通话失败", e);
if (type == 0) {
e.printStackTrace();
pageA = new Page(A);
if (PageUtil.isElementExist(pageA.voiceCallHangOn)) {
pageA.voiceCallHangOn.click();
}
}
}
}
日志信息
2015-07-29 11:12:28:766 - info: [debug] [INST] 2015-07-29 11:12:27 +0000 Debug: evaluating au.getElementsByName('免费电话')
2015-07-29 11:12:28:887 - info: [debug] Socket data received (96 bytes)
2015-07-29 11:12:28:887 - info: [debug] Socket data being routed.
2015-07-29 11:12:28:887 - info: [debug] Got result from instruments: {"status":0,"value":[{"ELEMENT":"481"},{"ELEMENT":"482"},{"ELEMENT":"483"},{"ELEMENT":"484"}]}
2015-07-29 11:12:28:888 - info: [debug] Responding to client with success: {"status":0,"value":[{"ELEMENT":"481"},{"ELEMENT":"482"},{"ELEMENT":"483"},{"ELEMENT":"484"}],"sessionId":"faf2e2fc-6e61-4ffb-9486-db9c6f99dc72"}
2015-07-29 11:12:28:888 - info: <-- POST /wd/hub/session/faf2e2fc-6e61-4ffb-9486-db9c6f99dc72/elements 200 1377.985 ms - 145 {"status":0,"value":[{"ELEMENT":"481"},{"ELEMENT":"482"},{"ELEMENT":"483"},{"ELEMENT":"484"}],"sessionId":"faf2e2fc-6e61-4ffb-9486-db9c6f99dc72"}
2015-07-29 11:12:28:893 - info: --> POST /wd/hub/session/faf2e2fc-6e61-4ffb-9486-db9c6f99dc72/timeouts/implicit_wait {"ms":5000}
2015-07-29 11:12:28:893 - info: [debug] Set iOS implicit wait to 5000ms
2015-07-29 11:12:28:893 - info: [debug] Responding to client with success: {"status":0,"value":null,"sessionId":"faf2e2fc-6e61-4ffb-9486-db9c6f99dc72"}
2015-07-29 11:12:28:894 - info: <-- POST /wd/hub/session/faf2e2fc-6e61-4ffb-9486-db9c6f99dc72/timeouts/implicit_wait 200 0.916 ms - 76 {"status":0,"value":null,"sessionId":"faf2e2fc-6e61-4ffb-9486-db9c6f99dc72"}
2015-07-29 11:12:28:898 - info: --> POST /wd/hub/session/faf2e2fc-6e61-4ffb-9486-db9c6f99dc72/element/481/click {"id":"481"}
2015-07-29 11:12:28:898 - info: [debug] Pushing command to appium work queue: "au.tapById('481')"
2015-07-29 11:12:28:898 - info: [debug] Sending command to instruments: au.tapById('481')
2015-07-29 11:12:28:924 - info: [debug] [INST] 2015-07-29 11:12:28 +0000 Debug: evaluation finished
2015-07-29 11:12:29:101 - info: [debug] [INST] 2015-07-29 11:12:28 +0000 Debug: Lookup returned [object UIAButton] with the name "免费电话" (id: 481).
2015-07-29 11:12:29:226 - info: [debug] [INST] 2015-07-29 11:12:28 +0000 Debug: Lookup returned [object UIAButton] with the name "免费电话" (id: 482).
2015-07-29 11:12:29:315 - info: [debug] [INST] 2015-07-29 11:12:28 +0000 Debug: Lookup returned [object UIAButton] with the name "免费电话" (id: 483).
2015-07-29 11:12:29:471 - info: [debug] [INST] 2015-07-29 11:12:28 +0000 Debug: Lookup returned [object UIAStaticText] with the name "免费电话" (id: 484).
2015-07-29 11:12:29:597 - info: [debug] [INST] 2015-07-29 11:12:28 +0000 Debug: responding with:
2015-07-29 11:12:29:701 - info: [debug] [INST] 2015-07-29 11:12:28 +0000 Debug: Running system command #723: /usr/local/Cellar/node/0.12.4/bin/node /usr/local/lib/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":0,"value":[{"ELEMENT":"481"},{"ELEMENT":"482"},{"ELEMENT":"483"},{"ELEMENT":"484"}]}...
2015-07-29 11:12:29:887 - info: [debug] [INST] 2015-07-29 11:12:29 +0000 Debug: Got new command 723 from instruments: au.tapById('481')
2015-07-29 11:12:29:984 - info: [debug] [INST] 2015-07-29 11:12:29 +0000 Debug: evaluating au.tapById('481')
2015-07-29 11:12:30:079 - info: [debug] [INST] 2015-07-29 11:12:29 +0000 Debug: UIAButton.tap()
2015-07-29 11:12:30:137 - info: [debug] Socket data received (25 bytes)
2015-07-29 11:12:30:138 - info: [debug] Socket data being routed.
2015-07-29 11:12:30:138 - info: [debug] Got result from instruments: {"status":0,"value":""}
2015-07-29 11:12:30:138 - info: [debug] Responding to client with success: {"status":0,"value":"","sessionId":"faf2e2fc-6e61-4ffb-9486-db9c6f99dc72"}
2015-07-29 11:12:30:139 - info: <-- POST /wd/hub/session/faf2e2fc-6e61-4ffb-9486-db9c6f99dc72/element/481/click 200 1240.808 ms - 74 {"status":0,"value":"","sessionId":"faf2e2fc-6e61-4ffb-9486-db9c6f99dc72"}
2015-07-29 11:12:30:192 - info: [debug] [INST] 2015-07-29 11:12:29 +0000 Debug: evaluation finished
2015-07-29 11:12:30:305 - info: [debug] [INST] 2015-07-29 11:12:29 +0000 Debug: responding with:
2015-07-29 11:12:30:453 - info: [debug] [INST] 2015-07-29 11:12:29 +0000 Debug: Running system command #724: /usr/local/Cellar/node/0.12.4/bin/node /usr/local/lib/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":0,"value":""}...
2015-07-29 11:12:36:764 - info: [debug] [INST] 2015-07-29 11:12:36 +0000 Fail: The target application appears to have died
2015-07-29 11:12:37:782 - info: [debug] [INST STDERR] 2015-07-29 04:12:37.781 instruments[1291:21727] Attempting to set event horizon when core is not engaged, request ignored
2015-07-29 04:12:37.781 instruments[1291:21547] Attempting to set event horizon when core is not engaged, request ignored
2015-07-29 11:12:37:795 - info: [debug] [INST] Instruments Trace Complete (Duration : 1462.144531s; Output : /tmp/appium-instruments/instrumentscli0.trace)
2015-07-29 11:12:37:845 - info: [debug] [INSTSERVER] Instruments exited with code 0
2015-07-29 11:12:37:846 - info: [debug] Cleaning up after instruments exit
2015-07-29 11:12:37:846 - info: [debug] Instruments exited unexpectedly
2015-07-29 11:12:37:846 - info: [debug] Shutting down command proxy and ignoring any errors
2015-07-29 11:12:37:847 - info: [debug] Destroying instruments client socket.
2015-07-29 11:12:37:847 - info: [debug] Closing socket server.
2015-07-29 11:12:38:089 - info: [debug] Instruments socket server was closed
2015-07-29 11:12:38:091 - info: [debug] Stopping iOS log capture
2015-07-29 11:12:38:092 - info: [debug] Running ios sim reset flow
2015-07-29 11:12:38:093 - info: [debug] Killing the simulator process
2015-07-29 11:12:38:094 - info: [debug] Killing any other simulator daemons
2015-07-29 11:12:38:106 - info: [debug] Killall iOS Simulator
2015-07-29 11:12:38:275 - info: [debug] On a real device; cannot clean device state
2015-07-29 11:12:38:275 - info: [debug] Cleaning up appium session
2015-07-29 11:12:40:822 - info: --> POST /wd/hub/session/faf2e2fc-6e61-4ffb-9486-db9c6f99dc72/timeouts/implicit_wait {"ms":0}
2015-07-29 11:12:40:842 - info: <-- POST /wd/hub/session/faf2e2fc-6e61-4ffb-9486-db9c6f99dc72/timeouts/implicit_wait 404 19.532 ms - 40
2015-07-29 11:12:40:852 - info: --> POST /wd/hub/session/faf2e2fc-6e61-4ffb-9486-db9c6f99dc72/timeouts/implicit_wait {"ms":5000}
2015-07-29 11:12:40:856 - info: <-- POST /wd/hub/session/faf2e2fc-6e61-4ffb-9486-db9c6f99dc72/timeouts/implicit_wait 404 3.491 ms - 40
2015-07-29 11:12:40:868 - info: --> POST /wd/hub/session/faf2e2fc-6e61-4ffb-9486-db9c6f99dc72/timeouts/implicit_wait {"ms":0}
2015-07-29 11:12:40:870 - info: <-- POST /wd/hub/session/faf2e2fc-6e61-4ffb-9486-db9c6f99dc72/timeouts/implicit_wait 404 2.512 ms - 40
2015-07-29 11:12:40:882 - info: --> POST /wd/hub/session/faf2e2fc-6e61-4ffb-9486-db9c6f99dc72/timeouts/implicit_wait {"ms":5000}
2015-07-29 11:12:40:883 - info: <-- POST /wd/hub/session/faf2e2fc-6e61-4ffb-9486-db9c6f99dc72/timeouts/implicit_wait 404 0.747 ms - 40
2015-07-29 11:12:40:898 - info: --> POST /wd/hub/session/faf2e2fc-6e61-4ffb-9486-db9c6f99dc72/timeouts/implicit_wait {"ms":0}
2015-07-29 11:12:40:899 - info: <-- POST /wd/hub/session/faf2e2fc-6e61-4ffb-9486-db9c6f99dc72/timeouts/implicit_wait 404 0.824 ms - 40
2015-07-29 11:12:40:914 - info: --> POST /wd/hub/session/faf2e2fc-6e61-4ffb-9486-db9c6f99dc72/timeouts/implicit_wait {"ms":5000}
2015-07-29 11:12:40:915 - info: <-- POST /wd/hub/session/faf2e2fc-6e61-4ffb-9486-db9c6f99dc72/timeouts/implicit_wait 404 0.772 ms - 40
2015-07-29 11:12:40:930 - info: --> POST /wd/hub/session/faf2e2fc-6e61-4ffb-9486-db9c6f99dc72/timeouts/implicit_wait {"ms":0}
2015-07-29 11:12:40:930 - info: <-- POST /wd/hub/session/faf2e2fc-6e61-4ffb-9486-db9c6f99dc72/timeouts/implicit_wait 404 0.786 ms - 40
2015-07-29 11:12:40:947 - info: --> POST /wd/hub/session/faf2e2fc-6e61-4ffb-9486-db9c6f99dc72/timeouts/implicit_wait {"ms":5000}
2015-07-29 11:12:40:949 - info: <-- POST /wd/hub/session/faf2e2fc-6e61-4ffb-9486-db9c6f99dc72/timeouts/implicit_wait 404 2.261 ms - 40
2015-07-29 11:12:40:963 - info: --> POST /wd/hub/session/faf2e2fc-6e61-4ffb-9486-db9c6f99dc72/timeouts/implicit_wait {"ms":0}
2015-07-29 11:12:40:965 - info: <-- POST /wd/hub/session/faf2e2fc-6e61-4ffb-9486-db9c6f99dc72/timeouts/implicit_wait 404 2.282 ms - 40
2015-07-29 11:12:40:977 - info: --> POST /wd/hub/session/faf2e2fc-6e61-4ffb-9486-db9c6f99dc72/timeouts/implicit_wait {"ms":5000}