Swift UITesting error: Invalid escape sequence in literal. \U201c

前端 未结 2 1312
渐次进展
渐次进展 2021-01-04 21:27

I am building an automation suite using Xcode 7 with swift.

My app loads with the following Alert View:

Allow \"Light Alarm\" to access your location while

相关标签:
2条回答
  • 2021-01-04 22:06

    This seems to be a bug in Xcode when generating code during UI recording. Swift uses \u{NNNN} escape sequences in string literals, so

    app.alerts["Allow \u{201c}Light Alarm\u{201c} ..."]
    

    would be correct, or simply

    app.alerts["Allow “Light Alarm“ ..."]
    

    (Actually it should be "Allow “Light Alarm” ..." where the second quotation mark is U+201D = RIGHT DOUBLE QUOTATION MARK :)

    A similar issue for UI recorded code in Objective-C was reported in Incomplete universal character name in UI Testing.

    I do not know a workaround, it seems that the only thing you can do at present is to fix the code after recording (and sent a bug report to Apple).

    0 讨论(0)
  • 2021-01-04 22:26

    Installing Xcode 7.3 fixed this issue for me

    0 讨论(0)
提交回复
热议问题