Switching back original webview not working with iOSDriver

Salesforce Lookup values testing on iPad (iOS 8.4):

  • setup the Lookup value by launching a popup windows
  • switch to context to the popup window (a new tab in iOS Safari)
  • confirm the search results from the Lookup search (and the popup window / the iOS Safari tab is closed as well)
  • try to carry on the rest automation test (failed, see logs for details)

info: [debug] Remote debugger notified us of a new page listing
info: [debug] New page listing is same as old, doing nothing
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] got applicationSentData response
info: [debug] [REMOTE] Page loaded, verifying whether ready through readyState
info: [debug] [REMOTE] got applicationSentData response
info: [debug] [REMOTE] Got a blank data response from debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] {"__argument":{“WIRApplicationIdentifierKey”:“PID:21634”,“WIRListingKey”:{“1”:{“WIRTitleKey”:“New Lead ~ salesforce.com - Unlimited Edition”,“WIRTypeKey”:“WIRTypeWeb”,“WIRURLKey”:“https://rb–test04f–c.cs9.visual.force.com/apex/NewLead”,“WIRPageIdentifierKey”:1,“WIRConnectionIdentifierKey”:“347c91df-e375-40f9-ab50-85f92354dfb3”},“104”:{“WIRTitleKey”:“Search ~ salesforce.com - Unlimited Edition”,“WIRTypeKey”:“WIRTypeWeb”,“WIRURLKey”:“https://rb–test04f–c.cs9.visual.force.com/_ui/common/data/LookupPage?lkfm=j_id0%3Aform&lknm=j_id0%3Aform%3AnewLeadBlock%3AinputEvent&lkfield=00NU0000003pgDl&lkent=00Q&lktp=a11&lksrch=Edmonton%2C%20AB%2C%20CAN%20-%20Dec%2010%2C%202015”,“WIRPageIdentifierKey”:104,“WIRConnectionIdentifierKey”:“347c91df-e375-40f9-ab50-85f92354dfb3”}}},"__selector":"_rpc_applicationSentListing:"}
info: [debug] Remote debugger notified us of a new page listing
info: [debug] New page listing is same as old, doing nothing
info: [debug] [REMOTE] Checking document readyState
info: [debug] [REMOTE] Sending javascript command
info: [debug] [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] got applicationSentData response
info: [debug] [REMOTE] readyState was complete
info: [debug] [REMOTE] Page is ready, calling onload cbs
info: --> POST /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/context {“name”:“WEBVIEW_104”}
info: [debug] Attempting to set context to ‘WEBVIEW_104’
info: [debug] [REMOTE] Selecting page 104 and forwarding socket setup
info: [debug] [REMOTE] Sending _rpc_forwardSocketSetup: message to remote debugger
info: [debug] [REMOTE] {"__argument":{“WIRApplicationIdentifierKey”:“PID:21634”,“WIRConnectionIdentifierKey”:“347c91df-e375-40f9-ab50-85f92354dfb3”,“WIRSenderKey”:“945f1146-2aa3-4875-a4c2-21cace3c4ade”,“WIRPageIdentifierKey”:104},"__selector":"_rpc_forwardSocketSetup:"}
info: [debug] [REMOTE] Set sender key
info: [debug] [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] got applicationSentData response
info: [debug] [REMOTE] Enabled activity on page
info: [debug] [REMOTE] Checking document readyState
info: [debug] [REMOTE] Sending javascript command
info: [debug] [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] got applicationSentData response
info: [debug] [REMOTE] readyState was complete
info: [debug] Responding to client with success: {“status”:0,“value”:"",“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: <-- POST /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/context 200 6.549 ms - 74 {“status”:0,“value”:"",“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: --> POST /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/element {“using”:“id”,“value”:“searchFrame”}
info: [debug] Waiting up to 0ms for condition
info: [debug] [REMOTE] Executing ‘find_element’ atom in default context
info: [debug] [REMOTE] Sending javascript command
info: [debug] [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] got applicationSentData response
info: [debug] Responding to client with success: {“status”:0,“value”:{“ELEMENT”:“5173”},“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: <-- POST /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/element 200 10.330 ms - 90 {“status”:0,“value”:{“ELEMENT”:“5173”},“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: --> GET /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/element/5173/displayed {}
info: [debug] [REMOTE] Executing ‘is_displayed’ atom in default context
info: [debug] [REMOTE] Sending javascript command
info: [debug] [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] got applicationSentData response
info: [debug] Responding to client with success: {“status”:0,“value”:true,“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: <-- GET /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/element/5173/displayed 200 11.280 ms - 76 {“status”:0,“value”:true,“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: --> POST /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/element {“using”:“id”,“value”:“resultsFrame”}
info: [debug] Waiting up to 0ms for condition
info: [debug] [REMOTE] Executing ‘find_element’ atom in default context
info: [debug] [REMOTE] Sending javascript command
info: [debug] [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] got applicationSentData response
info: [debug] Responding to client with success: {“status”:0,“value”:{“ELEMENT”:“5174”},“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: <-- POST /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/element 200 9.947 ms - 90 {“status”:0,“value”:{“ELEMENT”:“5174”},“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: --> GET /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/element/5174/displayed {}
info: [debug] [REMOTE] Executing ‘is_displayed’ atom in default context
info: [debug] [REMOTE] Sending javascript command
info: [debug] [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] got applicationSentData response
info: [debug] Responding to client with success: {“status”:0,“value”:true,“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: <-- GET /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/element/5174/displayed 200 9.860 ms - 76 {“status”:0,“value”:true,“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: --> POST /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/elements {“using”:“css selector”,“value”:“frame[name=‘resultsFrame’],iframe[name=‘resultsFrame’]”}
info: [debug] Waiting up to 0ms for condition
info: [debug] [REMOTE] Executing ‘find_elements’ atom in default context
info: [debug] [REMOTE] Sending javascript command
info: [debug] [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] got applicationSentData response
info: [debug] Responding to client with success: {“status”:0,“value”:[{“ELEMENT”:“5175”}],“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: <-- POST /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/elements 200 10.353 ms - 92 {“status”:0,“value”:[{“ELEMENT”:“5175”}],“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: --> POST /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/frame {“id”:{“ELEMENT”:“5175”,“element-6066-11e4-a52e-4f735466cecf”:“5175”}}
info: [debug] [REMOTE] Executing ‘get_frame_window’ atom in default context
info: [debug] [REMOTE] Sending javascript command
info: [debug] [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] got applicationSentData response
info: [debug] Entering new web frame: :wdc:1438208231452
info: [debug] Responding to client with success: {“status”:0,“value”:{“WINDOW”:":wdc:1438208231452"},“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: <-- POST /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/frame 200 6.684 ms - 103 {“status”:0,“value”:{“WINDOW”:":wdc:1438208231452"},“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: --> POST /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/element {“using”:“link text”,“value”:“Edmonton, AB, CAN - Dec 10, 2015”}
info: [debug] Waiting up to 0ms for condition
info: [debug] [REMOTE] Wrapping script for frame :wdc:1438208231452
info: [debug] [REMOTE] Sending javascript command
info: [debug] [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] got applicationSentData response
info: [debug] Responding to client with success: {“status”:0,“value”:{“ELEMENT”:“5176”},“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: <-- POST /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/element 200 20.058 ms - 90 {“status”:0,“value”:{“ELEMENT”:“5176”},“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: --> GET /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/element/5176/displayed {}
info: [debug] [REMOTE] Wrapping script for frame :wdc:1438208231452
info: [debug] [REMOTE] Sending javascript command
info: [debug] [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] got applicationSentData response
info: [debug] Responding to client with success: {“status”:0,“value”:true,“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: <-- GET /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/element/5176/displayed 200 10.814 ms - 76 {“status”:0,“value”:true,“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: --> GET /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/element/5176/enabled {}
info: [debug] [REMOTE] Wrapping script for frame :wdc:1438208231452
info: [debug] [REMOTE] Sending javascript command
info: [debug] [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] got applicationSentData response
info: [debug] Responding to client with success: {“status”:0,“value”:true,“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: <-- GET /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/element/5176/enabled 200 9.269 ms - 76 {“status”:0,“value”:true,“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: --> POST /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/element {“using”:“link text”,“value”:“Edmonton, AB, CAN - Dec 10, 2015”}
info: [debug] Waiting up to 0ms for condition
info: [debug] [REMOTE] Wrapping script for frame :wdc:1438208231452
info: [debug] [REMOTE] Sending javascript command
info: [debug] [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] got applicationSentData response
info: [debug] Responding to client with success: {“status”:0,“value”:{“ELEMENT”:“5177”},“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: <-- POST /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/element 200 17.588 ms - 90 {“status”:0,“value”:{“ELEMENT”:“5177”},“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: --> GET /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/element/5177/displayed {}
info: [debug] [REMOTE] Wrapping script for frame :wdc:1438208231452
info: [debug] [REMOTE] Sending javascript command
info: [debug] [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] got applicationSentData response
info: [debug] Responding to client with success: {“status”:0,“value”:true,“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: <-- GET /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/element/5177/displayed 200 11.027 ms - 76 {“status”:0,“value”:true,“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: --> POST /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/element/5177/click {“id”:“5177”}
info: [debug] [REMOTE] Wrapping script for frame :wdc:1438208231452
info: [debug] [REMOTE] Sending javascript command
info: [debug] [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] got applicationSentData response
info: [debug] Responding to client with success: {“status”:0,“value”:null,“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: <-- POST /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/element/5177/click 200 35.279 ms - 76 {“status”:0,“value”:null,“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] got applicationSentData response
info: [debug] [REMOTE] Got a blank data response from debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] got applicationSentData response
info: [debug] [REMOTE] Got a blank data response from debugger
info: [debug] [REMOTE] got applicationSentData response
info: [debug] [REMOTE] Got a blank data response from debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] {"__argument":{“WIRApplicationIdentifierKey”:“PID:21634”,“WIRListingKey”:{“1”:{“WIRTitleKey”:“New Lead ~ salesforce.com - Unlimited Edition”,“WIRTypeKey”:“WIRTypeWeb”,“WIRURLKey”:“https://rb–test04f–c.cs9.visual.force.com/apex/NewLead”,“WIRPageIdentifierKey”:1,“WIRConnectionIdentifierKey”:“347c91df-e375-40f9-ab50-85f92354dfb3”}}},"__selector":"_rpc_applicationSentListing:"}
info: [debug] Remote debugger notified us of a new page listing
info: [debug] New page listing from remote debugger doesn’t contain current window, let’s assume it’s closed
info: [debug] Debugger already selected page 1, confirming that choice.
info: --> POST /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/context {“name”:“WEBVIEW_1”}
info: [debug] Attempting to set context to ‘WEBVIEW_1’
info: [debug] [REMOTE] Selecting page 1 and forwarding socket setup
info: [debug] [REMOTE] Sending _rpc_forwardSocketSetup: message to remote debugger
info: [debug] [REMOTE] {"__argument":{“WIRApplicationIdentifierKey”:“PID:21634”,“WIRConnectionIdentifierKey”:“347c91df-e375-40f9-ab50-85f92354dfb3”,“WIRSenderKey”:“945f1146-2aa3-4875-a4c2-21cace3c4ade”,“WIRPageIdentifierKey”:1},"__selector":"_rpc_forwardSocketSetup:"}
info: [debug] [REMOTE] Set sender key
info: [debug] [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] got applicationSentData response
info: [debug] [REMOTE] Enabled activity on page
info: [debug] [REMOTE] Checking document readyState
info: [debug] [REMOTE] Sending javascript command
info: [debug] [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] got applicationSentData response
info: [debug] [REMOTE] readyState was complete
info: [debug] Responding to client with success: {“status”:0,“value”:"",“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: <-- POST /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/context 200 6.009 ms - 74 {“status”:0,“value”:"",“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: --> POST /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/refresh {}
info: [debug] [REMOTE] Wrapping script for frame :wdc:1438208231452
info: [debug] [REMOTE] Sending javascript command
info: [debug] [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] Receiving data from remote debugger
info: [debug] [REMOTE] got applicationSentData response
info: [debug] Responding to client with error: {“status”:13,“value”:{“message”:“An unknown server-side error occurred while processing the command.”,“origValue”:“Did not get OK result from execute(). Result was: {“type”:“object”,“objectId”:”{\“injectedScriptId\”:6,\“id\”:1}",“className”:“Object”,“description”:“StaleElementReferenceError: Element does not exist in cache”}"},“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: <-- POST /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/refresh 500 7.797 ms - 404

bugs/issues:

  1. when the javascript closes the lookup tab, the iOSDriver server thinks it is “closed” per the logs

info: [debug] New page listing from remote debugger doesn’t contain current window, let’s assume it’s closed

  1. when iOSdriver tried to refresh the main page or some other web browser activities, the server doesn’t get the any information from cache. And the server side unknown error is observed. The errors are
    server: An unknown server-side error occurred while processing the command error code: 500
    client: error ccde: 404

logs:
occurred while processing the command.",“origValue”:“Did not get OK result from execute(). Result was: {“type”:“object”,“objectId”:”{\“injectedScriptId\”:6,\“id\”:1}",“className”:“Object”,“description”:“StaleElementReferenceError: Element does not exist in cache”}"},“sessionId”:“579b4851-5409-46ed-9c5c-8912205aa3ea”}
info: <-- POST /wd/hub/session/579b4851-5409-46ed-9c5c-8912205aa3ea/refresh 500 7.797 ms - 404

Please review the bug/issue and let me know if you have questions for me.

Appium server: 1.4.8
Appium Java client: 3.1.0