Getelement with predicate does not work with appium 1.2.2

text=“random text"
self.driver.find_element_by_ios_uiautomation(“tableViews()[0].cells().withPredicate(“name CONTAINS '”+ text +”’")”)

The above piece of code works fine with appium 1.1.0 but fails to find the element in 1.2.2. Here are the logs for both 1.1.0 and 1.2.2
1.1.0:

info: Responding to client with success: {“status”:0,“value”:null,“sessionId”:“bebf3af9-952f-4395-a355-996452fa38de”}
POST /wd/hub/session/bebf3af9-952f-4395-a355-996452fa38de/element/21/click 200 275ms - 89b
debug: Appium request initiated at /wd/hub/session/bebf3af9-952f-4395-a355-996452fa38de/element
debug: Request received with params: {“using”:"-ios uiautomation",“sessionId”:“bebf3af9-952f-4395-a355-996452fa38de”,“value”:“tableViews()[0].cells().withPredicate(“name CONTAINS ‘NRSVK’”)”}
info: Pushing command to appium work queue: “au.getElementByUIAutomation(‘tableViews()[0].cells().withPredicate(\“name CONTAINS \‘NRSVK\’\”)’)”
debug: Sending command to instruments: au.getElementByUIAutomation(‘tableViews()[0].cells().withPredicate(“name CONTAINS ‘NRSVK’”)’)
info: [INSTSERVER] Sending command to instruments: au.getElementByUIAutomation(‘tableViews()[0].cells().withPredicate(“name CONTAINS ‘NRSVK’”)’)
info: [INSTSERVER] Socket data received (126 bytes)

1.2.2:

info: [debug] Pushing command to appium work queue: “au.getElementByUIAutomation(‘tableViews()[0].cells().withPredicate(\“name CONTAINS \‘8D2PJ\’\”)’)”
info: [debug] Sending command to instruments: au.getElementByUIAutomation(‘tableViews()[0].cells().withPredicate(“name CONTAINS ‘8D2PJ’”)’)
info: [debug] Sending command to instruments: au.getElementByUIAutomation(‘tableViews()[0].cells().withPredicate(“name CONTAINS ‘8D2PJ’”)’)
info: [debug] [INST] 2014-09-04 15:07:32 +0000 Debug: Got new command 39 from instruments: au.getElementByUIAutomation(‘tableViews()[0].cells().withPredicate(“name CONTAINS ‘8D2PJ’”)’)

info: [debug] [INST] 2014-09-04 15:07:32 +0000 Debug: evaluating au.getElementByUIAutomation(‘tableViews()[0].cells().withPredicate(“name CONTAINS ‘8D2PJ’”)’)

info: [debug] [INST] 2014-09-04 15:07:32 +0000 Debug: byUIAutomation: evaluating code: tableViews()[0].cells().withPredicate(“name CONTAINS ‘8D2PJ’”)

info: [debug] [INST] 2014-09-04 15:07:32 +0000 Error: ReferenceError: Can’t find variable: tableViews

info: [debug] Socket data received (57 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {“status”:17,“value”:“Can’t find variable: tableViews”}
info: [debug] Responding to client with error: {“status”:17,“value”:{“message”:“An error occurred while executing user supplied JavaScript.”,“origValue”:“Can’t find variable: tableViews”},“sessionId”:“8c795315-f422-4fcd-a851-5d90a10624fe”}
info: <-- POST /wd/hub/session/8c795315-f422-4fcd-a851-5d90a10624fe/element 500 117.238 ms - 192
info: [debug] [INST] 2014-09-04 15:07:32 +0000 Error: Error during eval: eval code
eval@[native code]
_getElementsByUIAutomation@file:///usr/local/lib/node_modules/appium/5070FA08-0FBF-43BD-8307-D87AD0D9BD1E/lookup-ext.js:157:23
getElementByUIAutomation@file:///usr/local/lib/node_modules/appium/5070FA08-0FBF-43BD-8307-D87AD0D9BD1E/lookup-ext.js:133:50
eval code

text=“random text"
self.driver.find_element_by_ios_uiautomation(".tableViews()[0].cells().withPredicate(“name CONTAINS '”+ text +"’")”)

use .tableViews() with a period.

1 Like

using a dot helped! .tableViews()

1 Like