Failed to run second loop while the first loop is ok

i was running a loop like below

while(i.hasNext()){
a= i.next();
launchPage.clickAddAccount();
login(a);
logout(a);
}
in first loop it runs well, but it dies when second loop begin at “launchPage.clickAddAccount();”

which is clicking a button, and the button it found.

can anybody tell me what’s wrong?

Here is the server log when error occours

info: [IOS_SYSLOG_ROW ] Jan 9 19:08:41 NetEasedeiMac.local CoreSimulatorBridge[80827]: Switching to keyboard: zh-Hans

info: [IOS_SYSLOG_ROW ] Jan 9 19:08:41 NetEasedeiMac.local CoreSimulatorBridge[80827]: KEYMAP: Failed to determine iOS keyboard layout for language zh-Hans.
info: [IOS_SYSLOG_ROW ] Jan 9 19:08:41 NetEasedeiMac.local CoreSimulatorBridge[80827]: Switching to keyboard: zh-Hans

info: [IOS_SYSLOG_ROW ] Jan 9 19:08:41 NetEasedeiMac.local CoreSimulatorBridge[80827]: KEYMAP: Failed to determine iOS keyboard layout for language zh-Hans.

info: --> POST /wd/hub/session/b92bf745-1c2f-4262-ab40-94e52afeaccb/element {“using”:“name”,“value”:“Add Account”}

info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: “au.getElementByName(‘Add Account’)”
info: [debug] Sending command to instruments: au.getElementByName(‘Add Account’)

info: [IOS_SYSLOG_ROW ] Jan 9 19:08:42 NetEasedeiMac.local CoreSimulatorBridge[80827]: Switching to keyboard: zh-Hans

info: [IOS_SYSLOG_ROW ] Jan 9 19:08:42 NetEasedeiMac.local CoreSimulatorBridge[80827]: KEYMAP: Failed to determine iOS keyboard layout for language zh-Hans.

info: [IOS_SYSLOG_ROW ] Jan 9 19:08:42 NetEasedeiMac.local CoreSimulatorBridge[80827]: Switching to keyboard: zh-Hans

info: [IOS_SYSLOG_ROW ] Jan 9 19:08:42 NetEasedeiMac.local CoreSimulatorBridge[80827]: KEYMAP: Failed to determine iOS keyboard layout for language zh-Hans.

info: [debug] [INST] 2015-01-09 11:08:42 +0000 Debug: Got new command 40 from instruments: au.getElementByName(‘Add Account’)

info: [debug] [INST] 2015-01-09 11:08:42 +0000 Debug: evaluating au.getElementByName(‘Add Account’)

info: [debug] [INST] 2015-01-09 11:08:42 +0000 Debug: evaluation finished

info: [debug] [INST] 2015-01-09 11:08:42 +0000 Debug: Lookup returned [object UIAButton] with the name “Add Account” (id: 15).

info: [debug] [INST] 2015-01-09 11:08:42 +0000 Debug: responding with:

info: [debug] [INST] 2015-01-09 11:08:42 +0000 Debug: Running system command #41: /Applications/Appium.app/Contents/Resources/node/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{“status”:0,“value”:{“ELEMENT”:“15”}}…

info: [debug] Socket data received (39 bytes)

info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {“status”:0,“value”:{“ELEMENT”:“15”}}
info: [debug] Responding to client with success: {“status”:0,“value”:{“ELEMENT”:“15”},“sessionId”:“b92bf745-1c2f-4262-ab40-94e52afeaccb”}
info: <-- POST /wd/hub/session/b92bf745-1c2f-4262-ab40-94e52afeaccb/element 200 1231.398 ms - 88 {“status”:0,“value”:{“ELEMENT”:“15”},“sessionId”:“b92bf745-1c2f-4262-ab40-94e52afeaccb”}

info: --> POST /wd/hub/session/b92bf745-1c2f-4262-ab40-94e52afeaccb/element/15/click {“id”:“15”}

info: [debug] Pushing command to appium work queue: “au.tapById(‘15’)”
info: [debug] Sending command to instruments: au.tapById(‘15’)

info: [IOS_SYSLOG_ROW ] Jan 9 19:08:43 NetEasedeiMac.local CoreSimulatorBridge[80827]: Switching to keyboard: zh-Hans

info: [IOS_SYSLOG_ROW ] Jan 9 19:08:43 NetEasedeiMac.local CoreSimulatorBridge[80827]: KEYMAP: Failed to determine iOS keyboard layout for language zh-Hans.
info: [IOS_SYSLOG_ROW ] Jan 9 19:08:43 NetEasedeiMac.local CoreSimulatorBridge[80827]: Switching to keyboard: zh-Hans
info: [IOS_SYSLOG_ROW ] Jan 9 19:08:43 NetEasedeiMac.local CoreSimulatorBridge[80827]: KEYMAP: Failed to determine iOS keyboard layout for language zh-Hans.

info: [debug] [INST] 2015-01-09 11:08:44 +0000 Debug: Got new command 41 from instruments: au.tapById(‘15’)

info: [debug] [INST] 2015-01-09 11:08:44 +0000 Debug: evaluating au.tapById(‘15’)

info: [debug] [INST] 2015-01-09 11:08:44 +0000 Debug: UIAButton.tap()

info: [debug] [INST] 2015-01-09 11:08:44 +0000 Debug: UIAButton could not be tapped

info: [debug] Socket data received (58 bytes)

info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {“status”:13,“value”:“elementId 15 could not be tapped”}
info: [debug] Responding to client with error: {“status”:13,“value”:{“message”:“An unknown server-side error occurred while processing the command.”,“origValue”:“elementId 15 could not be tapped”},“sessionId”:“b92bf745-1c2f-4262-ab40-94e52afeaccb”}
info: <-- POST /wd/hub/session/b92bf745-1c2f-4262-ab40-94e52afeaccb/element/15/click 500 1190.506 ms - 201

info: --> POST /wd/hub/session/b92bf745-1c2f-4262-ab40-94e52afeaccb/appium/app/close {}

info: [debug] Stopping ios
info: [debug] Destroying instruments client socket.
info: [debug] Closing socket server.

info: [debug] Instruments socket server was closed
info: [debug] Sending sigterm to instruments
info: [debug] [INST] 2015-01-09 11:08:44 +0000 Stopped: Script was stopped by the user
info: [IOS_SYSLOG_ROW ] Jan 9 19:08:44 NetEasedeiMac.local SpringBoard[80817]: Unable to get short BSD proc info for 80852: No such process

info: [IOS_SYSLOG_ROW ] Jan 9 19:08:44 NetEasedeiMac com.apple.CoreSimulator.SimDevice.B14B2444-EAE9-4D9D-9498-CE6A8FAD32BB.launchd_sim[80806] (UIKitApplication:d.netease.mail[0x4d49][80852]): Service exited due to signal: Killed: 9

info: [IOS_SYSLOG_ROW ] Jan 9 19:08:44 NetEasedeiMac.local SpringBoard[80817]: Application ‘UIKitApplication:d.netease.mail[0x4d49]’ exited abnormally via signal.

info: [IOS_SYSLOG_ROW ] Jan 9 19:08:44 NetEasedeiMac.local assertiond[80821]: notify_suspend_pid() failed with error 7

info: [IOS_SYSLOG_ROW ] Jan 9 19:08:44 NetEasedeiMac assertiond[80821]: assertion failed: 13E28 12B411: assertiond + 11523 [3F572A0B-7E12-378D-AFEE-EA491BAF2C36]: 0x1

info: [debug] [INST] 2015-01-09 11:08:44 +0000 Error: VerboseError: elementId 15 could not be tapped

info: [debug] [INST] 2015-01-09 11:08:44 +0000 Error: Error during eval: tapById@file:///Applications/Appium.app/Contents/Resources/node_modules/appium/5B1A2822-B32F-4E7F-9A7B-AAEB5026C0E9/bootstrap-a4a902c9cce7b6cb.js:1095:25
eval code
eval@[native code]
startProcessing@file:///Applications/Appium.app/Contents/Resources/node_modules/appium/5B1A2822-B32F-4E7F-9A7B-AAEB5026C0E9/bootstrap-a4a902c9cce7b6cb.js:2663:30
bootstrap@file:///Applications/Appium.app/Contents/Resources/node_modules/appium/5B1A2822-B32F-4E7F-9A7B-AAEB5026C0E9/bootstrap-a4a902c9cce7b6cb.js:2729:31
global code@file:///Applications/Appium.app/Contents/Resources/node_modules/appium/5B1A2822-B32F-4E7F-9A7B-AAEB5026C0E9/bootstrap-a4a902c9cce7b6cb.js:2738:10

info: [debug] [INST] 2015-01-09 11:08:44 +0000 Debug: responding with:
2015-01-09 11:08:44 +0000 Debug: Running system command #42: /Applications/Appium.app/Contents/Resources/node/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{“status”:13,“value”:“elementId 15 could not be tapped”}…

info: [debug] [INST] Instruments Trace Complete (Duration : 162.114685s; Output : /tmp/appium-instruments/instrumentscli0.trace)

info: [debug] [INSTSERVER] Instruments exited with code 0

I had the same issue before. The problem is that although the button is visible but for some reason we cannot click on it at the time the app finishes logging out.
My solution was to add more waiting time until the button is clickable by using: wait.until(ExpectedConditions.elementToBeClickable(By.name(elementName))); ( for java client)

1 Like

it seem you’re right, after i add wait statement, it returned timeout exception. now i am figuring out why same window in different place got different result

thanks for your help