Appium fails on finding elements after a swipe over app

Failure appears when i use SWIPE/or SCROLL to move on pages on a XCUIElementTypeTable and to fill some textfields value. After i swipe, next textfield find fails totally.

Using Appium 1.20 and ruby ( using cucumber, but can replicate with arc as well ) to automatize a iPhone application installed on a device. ( iphone11 )
The issue i encounter is when i try to fill into some textfields that aren’t visible on view ( from start ).
Flow:
1: type in into a textfield visible : success
2: swipe up ( so i see the 2nd page ) : success
3: type into a textfield that i see visible on my iphone : Fail.

cmds:

arc appium.txt

( i go to the specific form )
[12] pry(main)>

a=driver.textfields()

=> [#<Selenium::WebDriver::Element:0x…fe517fc548a16b430 id=“69000000-0000-0000-9902-000000000000”>,
#<Selenium::WebDriver::Element:0x7bf59f036b6c6426 id=“72000000-0000-0000-9902-000000000000”>,
#<Selenium::WebDriver::Element:0x…fa60169f0d053ee9a id=“7A000000-0000-0000-9902-000000000000”>,
#<Selenium::WebDriver::Element:0x…fe7b5fca80cae067c id=“85000000-0000-0000-9902-000000000000”>,
#<Selenium::WebDriver::Element:0x7dcb3c03f9461356 id=“8B000000-0000-0000-9902-000000000000”>,
#<Selenium::WebDriver::Element:0x…fc8c56b49207f7724 id=“91000000-0000-0000-9902-000000000000”>,
#<Selenium::WebDriver::Element:0x…fb6772ff772911cc6 id=“97000000-0000-0000-9902-000000000000”>]
[13] pry(main)> a.count
=> 7

driver.textfield(“tf_address_name”).send_keys “A QA Address”
driver.button(“Done”).click
( Success )

#driver.swipe direction:“up”
driver.execute_script “mobile:swipe”, direction: “up” ( Success )

a=driver.textfields()

At this point, the application on iphone frozes, and there’s a incomin error
-gives stale response webDriverAgentLib fault.
-XCTPerformOnMainRunLoop work timed out after 60.0s

The below commands won’t succeed at any cost. Could use find_elements, find_element, the application froze and best i get a timeout from WDA.
Any clues what I could do?

This is what i need more: > driver.textfield(“tf_clientno”).send_keys “QA TX Demo123”

driver.button(“Done”).click
driver.button(“tf_use_gps”).click
driver.button(“tf_add_address”).click

this is not Appium command.

I would try to simply click the invisible text field first. XCTest may scroll to it automatically

textfields it’s just a wrapper over find_elements, for all XCUIElementText…

Tried, it’s making the scroll to, but fails when trying to click on it and add text

[HTTP] {“using”:“accessibility id”,“value”:“tf_clientno”}
[debug] [W3C (5235a35d)] Calling AppiumDriver.findElement() with args: [“accessi bility id”,“tf_clientno”,“5235a35d-02ee-47f3-a33b-4a0fc06f0dac”]
[debug] [XCUITest] Executing command ‘findElement’
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, name, class name, -ios predicate string, -ios class chain, accessibility id
[debug] [BaseDriver] Waiting up to 0 ms for condition
[debug] [WD Proxy] Matched ‘/element’ to command name ‘findElement’
[debug] [WD Proxy] Proxying [POST /element] to [POST http://127.0.0.1:8822/sessi on/12F53FB8-779A-4FB7-BDC4-4F5ADB2F5C1B/element] with body: {“using”:“accessibil ity id”,“value”:“tf_clientno”}
[Xcode] 2021-01-25 09:23:54.914397+0200 WebDriverAgentRunner-Runner[753:564555] Getting the most recent active application (out of 1 total items)
[Xcode]
[Xcode] t = 146.78s Get all elements bound by accessibility element for: E lements matching predicate ‘wdName == “tf_clientno” AND (1 == 1 OR identifier == 0 OR frame == 0 OR value == 0 OR title == 0 OR label == 0 OR elementType == 0 O R enabled == 0 OR placeholderValue == 0 OR selected == 0)’
[Xcode]
[Xcode] t = 146.78s Requesting snapshot of accessibility hierarchy for app with pid 756
[Xcode]
[Xcode] t = 146.93s Find: Descendants matching type Any
[Xcode]
[Xcode] t = 146.94s Find: Elements matching predicate ‘wdName == “tf_c lientno” AND (1 == 1 OR identifier == 0 OR frame == 0 OR value == 0 OR title == 0 OR label == 0 OR elementType == 0 OR enabled == 0 OR placeholderValue == 0 OR selected == 0)’
[Xcode]
[Xcode] t = 146.94s Checking existence of "tf_clientno" TextField
[Xcode]
[Xcode] t = 146.94s Requesting snapshot of accessibility hierarchy for app with pid 756
[Xcode]
[Xcode] t = 147.06s Find: Descendants matching type Any
[Xcode]
[Xcode] t = 147.06s Find: Elements matching predicate ‘wdName == “tf_c lientno” AND (1 == 1 OR identifier == 0 OR frame == 0 OR value == 0 OR title == 0 OR label == 0 OR elementType == 0 OR enabled == 0 OR placeholderValue == 0 OR selected == 0)’
[Xcode]
[Xcode] t = 147.06s Find: Identity Binding
[Xcode]
[debug] [WD Proxy] Got response with status 200: {“value”:{“ELEMENT”:“E7000000-0 000-0000-F402-000000000000”,“element-6066-11e4-a52e-4f735466cecf”:“E7000000-0000 -0000-F402-000000000000”},“sessionId”:“12F53FB8-779A-4FB7-BDC4-4F5ADB2F5C1B”}
[debug] [W3C (5235a35d)] Responding to client with driver.findElement() result: {“element-6066-11e4-a52e-4f735466cecf”:“E7000000-0000-0000-F402-000000000000”,“E LEMENT”:“E7000000-0000-0000-F402-000000000000”}
[HTTP] <-- POST /wd/hub/session/5235a35d-02ee-47f3-a33b-4a0fc06f0dac/element 200 318 ms - 137
[HTTP]
[HTTP] --> POST /wd/hub/session/5235a35d-02ee-47f3-a33b-4a0fc06f0dac/element/E70 00000-0000-0000-F402-000000000000/value
[HTTP] {“value”:[“Q”,“A”," “,“T”,“X”,” “,“D”,“e”,“m”,“o”,“1”,“2”,“3”],“text”:“QA TX Demo123”}
[debug] [W3C (5235a35d)] Calling AppiumDriver.setValue() with args: [[“Q”,“A”,” “,“T”,“X”,” ",“D”,“e”,“m”,“o”,“1”,“2”,“3”],"E7000000-0000-0000-F402-000000000000 “,“5235a35d-02ee-47f3-a33b-4a0fc06f0dac”]
[debug] [XCUITest] Executing command ‘setValue’
[debug] [WD Proxy] Matched ‘/element/E7000000-0000-0000-F402-000000000000/value’ to command name ‘setValue’
[debug] [Protocol Converter] Added ‘text’ property “QA TX Demo123” to ‘setValue’ request body
[debug] [WD Proxy] Proxying [POST /element/E7000000-0000-0000-F402-000000000000/ value] to [POST http://127.0.0.1:8822/session/12F53FB8-779A-4FB7-BDC4-4F5ADB2F5C 1B/element/E7000000-0000-0000-F402-000000000000/value] with body: {“value”:[“Q”, “A”,” “,“T”,“X”,” “,“D”,“e”,“m”,“o”,“1”,“2”,“3”],“text”:“QA TX Demo123”}
[Xcode] t = 147.09s Requesting snapshot of accessibility hierarchy for app with pid 756
[Xcode]
[Xcode] t = 147.20s Find: Descendants matching type Any
[Xcode]
[Xcode] t = 147.20s Find: Elements matching predicate ‘wdName == “tf_clien tno” AND (1 == 1 OR identifier == 0 OR frame == 0 OR value == 0 OR title == 0 OR label == 0 OR elementType == 0 OR enabled == 0 OR placeholderValue == 0 OR sele cted == 0)’
[Xcode]
[Xcode] t = 147.20s Find: Identity Binding
[Xcode]
[Xcode] 2021-01-25 09:23:55.344761+0200 WebDriverAgentRunner-Runner[753:564555] Neither the “XCUIElementTypeTextField (tf_clientno)” element itself nor its acce ssible descendants have the keyboard input focus
[Xcode]
[Xcode] 2021-01-25 09:23:55.344872+0200 WebDriverAgentRunner-Runner[753:564555] Trying to tap the “XCUIElementTypeTextField (tf_clientno)” element to have it fo cused
[Xcode] t = 147.21s Tap “tf_clientno” TextField
[Xcode] t = 147.21s Wait for com.companymileage.iphonedevapp to idle
[Xcode]
[Xcode] t = 147.21s Find the “tf_clientno” TextField
[Xcode]
[Xcode] t = 147.21s Requesting snapshot of accessibility hierarchy for app with pid 756
[Xcode]
[Xcode] t = 147.32s Find: Descendants matching type Any
[Xcode]
[Xcode] t = 147.32s Find: Elements matching predicate 'wdName == " tf_clientno” AND (1 == 1 OR identifier == 0 OR frame == 0 OR value == 0 OR title == 0 OR label == 0 OR elementType == 0 OR enabled == 0 OR placeholderValue == 0 OR selected == 0)’
[Xcode]
[Xcode] t = 147.32s Find: Identity Binding
[Xcode]
[Xcode] t = 147.33s Check for interrupting elements affecting “tf_clie ntno” TextField
[Xcode]
[Xcode] t = 147.33s Requesting snapshot of accessibility hierarchy for app with pid 756
[Xcode]
[Xcode] t = 147.40s Find: Descendants matching predicate identifie r == “NotificationShortLookView” OR elementType == 7
[Xcode]
[Xcode] t = 147.41s Synthesize event
[Xcode]
[Xcode] t = 147.43s Scroll element to visible
[Xcode]
[Xcode] t = 147.44s Find the “tf_clientno” TextField
[Xcode]
[Xcode] t = 147.44s Requesting snapshot of accessibility hiera rchy for app with pid 756
[Xcode]
[Xcode] t = 147.67s Find: Descendants matching type Any
[Xcode]
[Xcode] t = 147.67s Find: Elements matching predicate ‘wdName == “tf_clientno” AND (1 == 1 OR identifier == 0 OR frame == 0 OR value == 0 OR t itle == 0 OR label == 0 OR elementType == 0 OR enabled == 0 OR placeholderValue == 0 OR selected == 0)’
[Xcode]
[Xcode] t = 147.68s Find: Identity Binding
[Xcode]
[Xcode] t = 148.69s Find the “tf_clientno” TextField (retry 1)
[Xcode]
[Xcode] t = 148.69s Requesting snapshot of accessibility h ierarchy for app with pid 756
[Xcode]
[Xcode] t = 148.89s Find: Descendants matching type Any
[Xcode]
[Xcode] t = 148.89s Find: Elements matching predicate ‘wdN ame == “tf_clientno” AND (1 == 1 OR identifier == 0 OR frame == 0 OR value == 0 OR title == 0 OR label == 0 OR elementType == 0 OR enabled == 0 OR placeholderVa lue == 0 OR selected == 0)’
[Xcode]
[Xcode] t = 148.89s Find: Identity Binding
[Xcode]
[Xcode] t = 149.90s Find the “tf_clientno” TextField (retry 2)
[Xcode]
[Xcode] t = 149.91s Requesting snapshot of accessibility h ierarchy for app with pid 756
[Xcode]
[Xcode] t = 151.60s Find: Descendants matching type Any
[Xcode]
[Xcode] t = 151.61s Find: Elements matching predicate ‘wdN ame == “tf_clientno” AND (1 == 1 OR identifier == 0 OR frame == 0 OR value == 0 OR title == 0 OR label == 0 OR elementType == 0 OR enabled == 0 OR placeholderVa lue == 0 OR selected == 0)’
[Xcode]
[Xcode] t = 151.61s Find: Identity Binding
[Xcode]
[Xcode] t = 151.62s Collecting extra data to assist test failu re triage
[Xcode]
[Xcode] t = 151.62s Requesting snapshot of accessibility h ierarchy for app with pid 756
[Xcode]
[WD Proxy] Error: timeout of 640000000ms exceeded
[WD Proxy] at createError (/usr/local/Cellar/appium/1.20.1/libexec/lib/node_modules/appium/node_modules/appium-xcuitest-driver/node_modules/axios/lib/core/createError.js:16:15)
[WD Proxy] at RedirectableRequest.handleRequestTimeout (/usr/local/Cellar/appium/1.20.1/libexec/lib/node_modules/appium/node_modules/appium-xcuitest-driver/node_modules/axios/lib/adapters/http.js:280:16)
[WD Proxy] at Object.onceWrapper (node:events:486:26)
[WD Proxy] at RedirectableRequest.emit (node:events:379:20)
[WD Proxy] at ClientRequest.eventHandlers. (/usr/local/Cellar/appium/1.20.1/libexec/lib/node_modules/appium/node_modules/appium-xcuitest-driver/node_modules/follow-redirects/index.js:13:24)
[WD Proxy] at ClientRequest.emit (node:events:379:20)
[WD Proxy] at Socket.emitRequestTimeout (node:_http_client:812:9)
[WD Proxy] at Object.onceWrapper (node:events:485:28)
[WD Proxy] at Socket.emit (node:events:391:22)
[WD Proxy] at Socket._onTimeout (node:net:482:8)
[WD Proxy] at listOnTimeout (node:internal/timers:556:17)
[WD Proxy] at processTimers (node:internal/timers:499:7)
[debug] [W3C (5235a35d)] Encountered internal error running command: UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: timeout of 640000000ms exceeded
[debug] [W3C (5235a35d)] at JWProxy.command (/usr/local/Cellar/appium/1.20.1/libexec/lib/node_modules/appium/node_modules/appium-xcuitest-driver/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:275:13)
[debug] [W3C (5235a35d)] at runMicrotasks ()
[debug] [W3C (5235a35d)] at processTicksAndRejections (node:internal/process/task_queues:94:5)
[debug] [W3C (5235a35d)] at XCUITestDriver.proxyCommand (/usr/local/Cellar/appium/1.20.1/libexec/lib/node_modules/appium/node_modules/appium-xcuitest-driver/lib/commands/proxy-helper.js:96:12)
[debug] [W3C (5235a35d)] at XCUITestDriver.setValue (/usr/local/Cellar/appium/1.20.1/libexec/lib/node_modules/appium/node_modules/appium-xcuitest-driver/lib/commands/element.js:152:5)
[HTTP] <-- POST /wd/hub/session/5235a35d-02ee-47f3-a33b-4a0fc06f0dac/element/E7000000-0000-0000-F402-000000000000/value 500 60068 ms - 1071
[HTTP]
[Xcode] t = 211.63s Requesting snapshot of accessibility hierarchy for app with pid 756
[Xcode]

The app frozes after the scroll to make button visible.

Make sure you don’t interact with the same cached webelement after the scroll happens. Try to locate it one more time

Yes, this is what i did, got stalled reference.
The problem is after i focus on that button, the WDA seems frozing.
I tried an arc run ( appium ruby console ) and managed to get focus on that field, but if i clear and type again, app frozes.

[WD Proxy] Error: timeout of 640000000ms exceeded
[WD Proxy] at createError (/usr/local/Cellar/appium/1.20.1/libexec/lib/node_modules/appium/node_modules/appium-xcuitest-driver/node_modules/axios/lib/core/createError.js:16:15)
[WD Proxy] at RedirectableRequest.handleRequestTimeout (/usr/local/Cellar/appium/1.20.1/libexec/lib/node_modules/appium/node_modules/appium-xcuitest-driver/node_modules/axios/lib/adapters/http.js:280:16)
[WD Proxy] at Object.onceWrapper (node:events:486:26)
[WD Proxy] at RedirectableRequest.emit (node:events:379:20)
[WD Proxy] at ClientRequest.eventHandlers. (/usr/local/Cellar/appium/1.20.1/libexec/lib/node_modules/appium/node_modules/appium-xcuitest-driver/node_modules/follow-redirects/index.js:13:24)
[WD Proxy] at ClientRequest.emit (node:events:379:20)
[WD Proxy] at Socket.emitRequestTimeout (node:_http_client:812:9)
[WD Proxy] at Object.onceWrapper (node:events:485:28)
[WD Proxy] at Socket.emit (node:events:391:22)
[WD Proxy] at Socket._onTimeout (node:net:482:8)
[WD Proxy] at listOnTimeout (node:internal/timers:556:17)
[WD Proxy] at processTimers (node:internal/timers:499:7)
[debug] [W3C (0dd7cf82)] Encountered internal error running command: UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: timeout of 640000000ms exceeded
[debug] [W3C (0dd7cf82)] at JWProxy.command (/usr/local/Cellar/appium/1.20.1/libexec/lib/node_modules/appium/node_modules/appium-xcuitest-driver/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:275:13)
[debug] [W3C (0dd7cf82)] at runMicrotasks ()
[debug] [W3C (0dd7cf82)] at processTicksAndRejections (node:internal/process/task_queues:94:5)
[debug] [W3C (0dd7cf82)] at XCUITestDriver.proxyCommand (/usr/local/Cellar/appium/1.20.1/libexec/lib/node_modules/appium/node_modules/appium-xcuitest-driver/lib/commands/proxy-helper.js:96:12)
[debug] [W3C (0dd7cf82)] at XCUITestDriver.setValue (/usr/local/Cellar/appium/1.20.1/libexec/lib/node_modules/appium/node_modules/appium-xcuitest-driver/lib/commands/element.js:152:5)
[HTTP] ← POST /wd/hub/session/0dd7cf82-5db4-45c6-a0fb-b4bf9f24e881/element/8B000000-0000-0000-3103-000000000000/value

Any way to set “no-cache” for a test flow? so will request properly on each step?

it is mostly in a way you write code.

// looks like you way is
MobileElement el = driver.findElement(xxxx);
el.clear();
el.setValue("my_text")
el.doSomething

// approach one:
function clear(By searchString) {
  MobileElement el = driver.findElement(searchString);
  el.clear();
}

// second one using annotations
@iOSXCUITFindBy(id = "someID")
@AndroidFindBy(id = "someID")
private MobileElement myButton;

public tapMyButton() {
    tap(myButton); // every mention of 'myButton' invocates annotation to search element
}

yes, i do these in ruby ( in cucumber ) in defs ( functions ) i have usually a clear/setvalue/sleep 1

a simple flow is
Given I am logged in and I am on the addresses page
When I tap on the plus sign from the top right corner
Then the add new address form should appear
Then I complete Address Name
Then I scroll to client id
And I complete client id
When I tap on Capture Address to complete fields Address1 City State Zip with the data of the current location

def fill_in_address_name( txtName = “default”)
# addr = tap_on(“txt_address_name”, false)
addr = extract_from_mappings(@mappings, translate(“txt_address_name”))
txt = translate(txtName, “DATA.ADDRESS”)
fill_in addr, txt
sleep 1
press_done
end

def press_done
elems = $driver.find_elements(:accessibility_id, “btn_keyboard_done”)
if (elems.count > 0)
elems.first.click
sleep 1
return true
end
return false
end

def fill_in(el, text, doClear = 1 )
$logger.info(“Adding #{el} using type match by #{el[‘selector_type’]} with value #{text}”)
element = $driver.find_element(el[‘selector_type’].downcase.to_sym, el[‘value’])
element.clear if doClear
element.send_keys text
end

each step is defined in a ruby function, that calls proper function ( clear & send_keys / scroll down )

Got some stalled error and retried, by that i managed to fill the scroll and text into client no ( on 2nd page ).
The issue is that pressing done button is not yet working.
Thanks for support, already managed to fix some issues, based on the comments above :slight_smile: