How to interact with two Flutter apps one after another?

I’d like to test launching my app with direct links. Due to Siri issue on real iOS device I wasn’t able to succeed with driver.get().

So I created a helper Flutter app which main purpose is to receive and launch direct link opening my app under test.

I was able to install and activate my helper app before test. But I’m not able to send text in TextField to launch my direct link. Appium seems just hang with ‘Requesting snapshot of accessibility hierarchy for app with pid 7555’ output.

print('Installing url launcher helper')
driver.switch_to.context('NATIVE_APP')
driver.install_app(path + '/test_url_launcher/build/ios/iphoneos/Runner.app')

print('Opening url launcher helper app...')
driver.activate_app('com.example.testUrlLauncher')

driver.switch_to.context('FLUTTER')

print('Finding text field...')
text_field_finder = finder.by_type('TextField')
# driver.execute_script('flutter:waitFor', text_field_finder, 500)
url_text_field = FlutterElement(driver, text_field_finder)

print('Setting url...')
url_text_field.send_keys(url)  

Logs

    [debug] [XCUITest] Successfully pushed 19 folders and 63 files within 13232ms
    [debug] [XCUITest] An upgrade of the existing application is going to be performed
    [Xcode]     t =  5306.72s Get all elements bound by index for: Elements matching predicate 'elementType IN {7, 5, 46}'
    [Xcode] 
    [Xcode]     t =  5306.72s     Requesting snapshot of accessibility hierarchy for app with pid 7345
    [Xcode] 
    [Xcode]     t =  5306.74s     Find: Descendants matching type Any
    [Xcode] 
    [Xcode]     t =  5306.74s     Find: Elements matching predicate 'elementType IN {7, 5, 46}'
    [Xcode] 
    [Xcode]     t =  5308.80s Get all elements bound by index for: Elements matching predicate 'elementType IN {7, 5, 46}'
    [Xcode]     t =  5308.80s     Requesting snapshot of accessibility hierarchy for app with pid 7345
    [Xcode] 
    [Xcode]     t =  5308.85s     Find: Descendants matching type Any
    [Xcode]     t =  5308.85s     Find: Elements matching predicate 'elementType IN {7, 5, 46}'
    [Xcode] 
    [XCUITest] App installation succeeded after 17870ms
    [XCUITestDriver@0dc4 (dcabea8e)] Installation of '/Users/oleksandrkostenko/Development/projects/memo-flutter-appium-test/test_url_launcher/build/ios/iphoneos/Runner.app' succeeded
    [debug] [FlutterDriver@a565 (ae0ab719)] Responding to client with driver.execute() result: null
    [HTTP] <-- POST /session/ae0ab719-6738-4bec-b0b1-30c0f3bd454f/execute/sync 200 17872 ms - 14
    [HTTP] 
    [HTTP] --> POST /session/ae0ab719-6738-4bec-b0b1-30c0f3bd454f/context
    [HTTP] {"name":"FLUTTER"}
    [debug] [FlutterDriver@a565 (ae0ab719)] Calling AppiumDriver.setContext() with args: ["FLUTTER","ae0ab719-6738-4bec-b0b1-30c0f3bd454f"]
    [debug] [FlutterDriver] Executing Flutter driver command 'setContext'
    [debug] [XCUITestDriver@0dc4 (dcabea8e)] Attempting to set context to 'NATIVE_APP' from 'NATIVE_APP'
    [debug] [XCUITestDriver@0dc4 (dcabea8e)] Already in 'NATIVE_APP' context. Doing nothing.
    [debug] [FlutterDriver@a565 (ae0ab719)] Responding to client with driver.setContext() result: null
    [HTTP] <-- POST /session/ae0ab719-6738-4bec-b0b1-30c0f3bd454f/context 200 1 ms - 14
    [HTTP] 
    [HTTP] --> POST /session/ae0ab719-6738-4bec-b0b1-30c0f3bd454f/context
    [HTTP] {"name":"NATIVE_APP"}
    [debug] [FlutterDriver@a565 (ae0ab719)] Calling AppiumDriver.setContext() with args: ["NATIVE_APP","ae0ab719-6738-4bec-b0b1-30c0f3bd454f"]
    [debug] [FlutterDriver] Executing Flutter driver command 'setContext'
    [debug] [XCUITestDriver@0dc4 (dcabea8e)] Attempting to set context to 'NATIVE_APP' from 'NATIVE_APP'
    [debug] [XCUITestDriver@0dc4 (dcabea8e)] Already in 'NATIVE_APP' context. Doing nothing.
    [debug] [FlutterDriver@a565 (ae0ab719)] Responding to client with driver.setContext() result: null
    [HTTP] <-- POST /session/ae0ab719-6738-4bec-b0b1-30c0f3bd454f/context 200 0 ms - 14
    [HTTP] 
    [HTTP] --> POST /session/ae0ab719-6738-4bec-b0b1-30c0f3bd454f/execute/sync
    [HTTP] {"script":"mobile: activateApp","args":[{"appId":"com.example.testUrlLauncher","bundleId":"com.example.testUrlLauncher"}]}
    [debug] [FlutterDriver@a565 (ae0ab719)] Calling AppiumDriver.execute() with args: ["mobile: activateApp",[{"appId":"com.example.testUrlLauncher","bundleId":"com.example.testUrlLauncher"}],"ae0ab719-6738-4bec-b0b1-30c0f3bd454f"]
    [debug] [FlutterDriver] Executing proxied driver command 'execute'
    [debug] [XCUITestDriver@0dc4 (dcabea8e)] Executing command 'execute'
    [BaseDriver] The following script arguments are not known and will be ignored: appId
    [debug] [XCUITestDriver@0dc4 (dcabea8e)] Proxying [POST /wda/apps/activate] to [POST http://127.0.0.1:8100/session/3A684694-C1A3-437C-B3A8-653BACA3F797/wda/apps/activate] with body: {"bundleId":"com.example.testUrlLauncher"}
    [Xcode]     t =  5310.09s Open com.example.testUrlLauncher
    [Xcode] 
    [Xcode]     t =  5310.09s     Launch com.example.testUrlLauncher
    [Xcode] 
    [Xcode]     t =  5310.44s         Setting up automation session
    [Xcode] 
    [Xcode] 2023-08-06 19:19:44.855928+0300 WebDriverAgentRunner-Runner[6179:274862] Waiting up to 10s until com.example.testUrlLauncher is in idle state (including animations)
    [Xcode]     t =  5311.01s         Wait for com.example.testUrlLauncher to idle
    [Xcode] 
    [Xcode]     t =  5312.55s Wait for com.example.testUrlLauncher to become Running Foreground
    [Xcode] 
    [debug] [XCUITestDriver@0dc4 (dcabea8e)] Got response with status 200: {"value":null,"sessionId":"3A684694-C1A3-437C-B3A8-653BACA3F797"}
    [debug] [FlutterDriver@a565 (ae0ab719)] Responding to client with driver.execute() result: null
    [HTTP] <-- POST /session/ae0ab719-6738-4bec-b0b1-30c0f3bd454f/execute/sync 200 2485 ms - 14
    [HTTP] 
    [HTTP] --> POST /session/ae0ab719-6738-4bec-b0b1-30c0f3bd454f/context
    [HTTP] {"name":"FLUTTER"}
    [debug] [FlutterDriver@a565 (ae0ab719)] Calling AppiumDriver.setContext() with args: ["FLUTTER","ae0ab719-6738-4bec-b0b1-30c0f3bd454f"]
    [debug] [FlutterDriver] Executing Flutter driver command 'setContext'
    [debug] [XCUITestDriver@0dc4 (dcabea8e)] Attempting to set context to 'NATIVE_APP' from 'NATIVE_APP'
    [debug] [XCUITestDriver@0dc4 (dcabea8e)] Already in 'NATIVE_APP' context. Doing nothing.
    [debug] [FlutterDriver@a565 (ae0ab719)] Responding to client with driver.setContext() result: null
    [HTTP] <-- POST /session/ae0ab719-6738-4bec-b0b1-30c0f3bd454f/context 200 0 ms - 14
    [HTTP] 
    [HTTP] --> POST /session/ae0ab719-6738-4bec-b0b1-30c0f3bd454f/element/eyJmaW5kZXJUeXBlIjoiQnlUeXBlIiwidHlwZSI6IlRleHRGaWVsZCJ9/value
    [HTTP] {"text":"https://www.google.com","value":["h","t","t","p","s",":","/","/","w","w","w",".","g","o","o","g","l","e",".","c","o","m"],"id":"eyJmaW5kZXJUeXBlIjoiQnlUeXBlIiwidHlwZSI6IlRleHRGaWVsZCJ9"}
    [debug] [FlutterDriver@a565 (ae0ab719)] Calling AppiumDriver.setValue() with args: [["h","t","t","p","s",":","/","/","w","w","w",".","g","o","o","g","l","e",".","c","o","m"],"eyJmaW5kZXJUeXBlIjoiQnlUeXBlIiwidHlwZSI6IlRleHRGaWVsZCJ9","ae0ab719-6738-4bec-b0b1-30c0f3bd454f"]
    [debug] [FlutterDriver] Executing Flutter driver command 'setValue'
    [debug] [FlutterDriver] >>> {"command":"tap","finderType":"ByType","type":"TextField"}
    [Xcode]     t =  5312.57s Get all elements bound by index for: Elements matching predicate 'elementType IN {7, 5, 46}'
    [Xcode] 
    [Xcode]     t =  5312.57s     Requesting snapshot of accessibility hierarchy for app with pid 7356
    [Xcode] 
    [Xcode]     t =  5312.60s     Find: Descendants matching type Any
    [Xcode] 
    [Xcode]     t =  5312.60s     Find: Elements matching predicate 'elementType IN {7, 5, 46}'
    [Xcode] 
    [Xcode]     t =  5314.65s Get all elements bound by index for: Elements matching predicate 'elementType IN {7, 5, 46}'
    [Xcode] 
    [Xcode]     t =  5314.65s     Requesting snapshot of accessibility hierarchy for app with pid 7356
    [Xcode] 
    [Xcode]     t =  5314.67s     Find: Descendants matching type Any
    [Xcode] 
    [Xcode]     t =  5314.67s     Find: Elements matching predicate 'elementType IN {7, 5, 46}'
    [Xcode] 
    [Xcode]     t =  5316.76s Get all elements bound by index for: Elements matching predicate 'elementType IN {7, 5, 46}'
    [Xcode]