Class chain query error on dollar sign

Hi team, I am doing Class Chain query including expression for descendants, it fails on dollar sign. But according to Class Chain Queries Construction Rules the dollar $ sign is used to query descendants.

Appium Version: 1.7.1

The request:

{“using”:“class chain”,“value”:“**/XCUIElementTypeCell[`visible == 1`][$type == ‘XCUIElementTypeStaticText’ AND name == ‘From’$]/XCUIElementTypeTextField”}

The result:
{
“value”: “Cannot parse class chain query ‘**/XCUIElementTypeCell[`visible == 1`][$type == ‘XCUIElementTypeStaticText’ AND name == ‘From’$]/XCUIElementTypeTextField’.
Unexpected character detected at position 40:\n**/XCUIElementTypeCell[`visible == 1`][$ <----\n\n(\n\t0 CoreFoundation 0x000000010bb1b1ab __exceptionPreprocess + 171\n\t1 libobjc.A.dylib 0x000000010b1b0f41 objc_exception_throw + 48\n\t2 WebDriverAgentLib 0x0000000121c88938 -[XCUIElement(FBClassChain) fb_descendantsMatchingClassChain:shouldReturnAfterFirstMatch:] + 376\n\t3 WebDriverAgentLib 0x0000000121ca3341 +[FBFindElementCommands elementsUsing:withValue:under:shouldReturnAfterFirstMatch:] + 897\n\t4 WebDriverAgentLib 0x0000000121ca242c +[FBFindElementCommands handleFindElements:] + 300\n\t5 WebDriverAgentLib 0x0000000121c90053 -[FBRoute_TargetAction mountRequest:intoResponse:] + 179\n\t6 WebDriverAgentLib 0x0000000121c87794 __37-[FBWebServer registerRouteHandlers:]_block_invoke + 548\n\t7 RoutingHTTPServer 0x0000000121d33c18 -[RoutingHTTPServer handleRoute:withRequest:response:] + 136\n\t8 RoutingHTTPServer 0x0000000121d344fa __72-[RoutingHTTPServer routeMethod:withPath:parameters:request:connection:]_block_invoke + 47\n\t9 libdispatch.dylib 0x000000011039f2b5 _dispatch_client_callout + 8\n\t10 libdispatch.dylib 0x00000001103aa999 _dispatch_sync_thread_bound_invoke + 108\n\t11 libdispatch.dylib 0x000000011039f2b5 _dispatch_client_callout + 8\n\t12 libdispatch.dylib 0x00000001103a9496 _dispatch_main_queue_callback_4CF + 1260\n\t13 CoreFoundation 0x000000010baddee9 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 9\n\t14 CoreFoundation 0x000000010baa2592 _CFRunLoopRun + 2402\n\t15 CoreFoundation 0x000000010baa19b9 CFRunLoopRunSpecific + 409\n\t16 Foundation 0x000000010abace5e -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 274\n\t17 WebDriverAgentLib 0x0000000121c8666a -[FBWebServer startServing] + 346\n\t18 WebDriverAgentRunner 0x0000000120e92fbe -[UITestingUITests testRunner] + 126\n\t19 CoreFoundation 0x000000010ba9f49c invoking + 140\n\t20 CoreFoundation 0x000000010ba9f370 -[NSInvocation invoke] + 320\n\t21 XCTest 0x000000010aa68125 __24-[XCTestCase invokeTest]_block_invoke + 591\n\t22 XCTest 0x000000010aab0a52 -[XCUITestContext performInScope:] + 183\n\t23 XCTest 0x000000010aa67ecb -[XCTestCase invokeTest] + 141\n\t24 XCTest 0x000000010aa68e8c __26-[XCTestCase performTest:]_block_invoke.369 + 42\n\t25 XCTest 0x000000010aab57f9 +[XCTContext runInContextForTestCase:block:] + 163\n\t26 XCTest 0x000000010aa68828 -[XCTestCase performTest:] + 608\n\t27 XCTest 0x000000010aa6482e __27-[XCTestSuite performTest:]_block_invoke + 363\n\t28 XCTest 0x000000010aa64195 -[XCTestSuite _performProtectedSectionForTest:testSection:] + 26\n\t29 XCTest 0x000000010aa64392 -[XCTestSuite performTest:] + 239\n\t30 XCTest 0x000000010aa6482e __27-[XCTestSuite performTest:]_block_invoke + 363\n\t31 XCTest 0x000000010aa64195 -[XCTestSuite _performProtectedSectionForTest:testSection:] + 26\n\t32 XCTest 0x000000010aa64392 -[XCTestSuite performTest:] + 239\n\t33 XCTest 0x000000010aa6482e __27-[XCTestSuite performTest:]_block_invoke + 363\n\t34 XCTest 0x000000010aa64195 -[XCTestSuite _performProtectedSectionForTest:testSection:] + 26\n\t35 XCTest 0x000000010aa64392 -[XCTestSuite performTest:] + 239\n\t36 XCTest 0x000000010aabcf23 __44-[XCTTestRunSession runTestsAndReturnError:]_block_invoke + 40\n\t37 XCTest 0x000000010aa77a0e -[XCTestObservationCenter _observeTestExecutionForBlock:] + 475\n\t38 XCTest 0x000000010aabcdc2 -[XCTTestRunSession runTestsAndReturnError:] + 281\n\t39 XCTest 0x000000010aa53e87 -[XCTestDriver runTestsAndReturnError:] + 314\n\t40 XCTest 0x000000010aab4a64 _XCTestMain + 619\n\t41 CoreFoundation 0x000000010babe18c CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK + 12\n\t42 CoreFoundation 0x000000010baa296b __CFRunLoopDoBlocks + 203\n\t43 CoreFoundation 0x000000010baa2144 __CFRunLoopRun + 1300\n\t44 CoreFoundation 0x000000010baa19b9 CFRunLoopRunSpecific + 409\n\t45 GraphicsServices 0x000000010ee189c6 GSEventRunModal + 62\n\t46 UIKit 0x000000010bf96948 UIApplicationMain + 159\n\t47 WebDriverAgentRunner-Runner 0x000000010a7ce838 WebDriverAgentRunner-Runner + 6200\n\t48 libdyld.dylib 0x0000000110413d81 start + 1\n\t49 ??? 0x0000000000000005 0x0 + 5\n)”,
“sessionId”: “32D1C9B2-5632-4DC5-881A-2DDE67614576”,
“status”: 13
}

Query expression:
**/XCUIElementTypeCell[`visible == 1`][$type == ‘XCUIElementTypeStaticText’ AND name == ‘From’$]/XCUIElementTypeTextField

From the link you provided:

Use `` or $$ to escape a single ` or $ character inside predicate expression.

Could you try that?

The request with $$ looks like this

{“using”:“class chain”,“value”:“**/XCUIElementTypeCell[`visible == 1`][$$type == ‘XCUIElementTypeStaticText’ AND name == ‘From’$$]/XCUIElementTypeTextField”}

Which response is

{
“value”: "Cannot parse class chain query ‘**/XCUIElementTypeCell[`visible == 1`][$$type == ‘XCUIElementTypeStaticText’ AND name == ‘From’$$]/XCUIElementTypeTextField’.
Unexpected character detected at position 40:\n**/XCUIElementTypeCell[`visible == 1`][$ <----\n\n(\n\t0 CoreFoundation 0x000000010bb1b1ab __exceptionPreprocess + 171\n\t1 …

When I read the example expressions from the link you provided, all of them use backticks on the visible property, such as:

[`visible == 1`]

But your expression does not seem to do that. Is it a problem with the formatting on this board, or did you leave that out (and can you add it if so?).

Yes, it was formatting issue on this page, all examples are having the " ` " for “visible” attribute expression (thank you @wreed for noticing that, all examples are corrected now to show backticks). My expressions are based on documentation example.

Never mind! It was published with [email protected] within the WDA#707 commit. Mine was older.

@Murdoc how did you solve this problem?
I also get the error message that the dollar sign could not be parsed. I also tried to escape the dollar sign with backslashes but i didn’t work.

Edit: An update of the appium server from 1.7.1 to the newest version (1.8.1-beta3) worked for me