-
Notifications
You must be signed in to change notification settings - Fork 367
Tips and Tricks
This page contains different tips and info that may be relevant to building better tests with Calabash iOS.
Often you'd want to reset app data between scenarios. This is a new feature from version 0.9.48. To be backwards compatible, however, it is not enabled by default, and is opt in. To enable use environment variable RESET_BETWEEN_SCENARIOS=1
$ RESET_BETWEEN_SCENARIOS=1 OS=ios5 cucumber
If you want to send your screenshots to a specific directory, use SCREENSHOT_PATH
$ SCREENSHOT_PATH=./screenshots/ cucumber
By default the calabash-ios console command will read the .irbrc in the current directory. To override this behavior use the CALABASH_IRBRC variable.
$ CALABASH_IRBRC=~/.irbrc calabash-ios console
The query language that Calabash uses single quotes ' to delimit strings. This has an unfortunate interaction with the Ruby API.
What this means is that strings that contain single quotes must be escaped in a special way. With Calabash-iOS 0.9.53 this is partially remedied.
-
A new function
escape_quotesis introduced in operations.rb. To use, callescape_quoteson a string containing quotes like"Karl's". This gives a new string that you can pass toqueryand the other operations. -
The previous difference between touch and query in handling of quotes should disappear.
Example:
irb(main):001:0> txt = "karl's"
=> "karl's"
irb(main):002:0> txt = escape_quotes("karl's")
=> "karl\\'s"
irb(main):003:0> query("view marked:'#{txt}'")
=> ["<UIRoundedRectButton: 0x7e95840; frame = (100 287; 72 37); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x7e95700>>"]
irb(main):004:0> touch("view marked:'#{txt}'")
=> ["<UIRoundedRectButton: 0x7e95840; frame = (100 287; 72 37); opaque = NO; autoresize = RM+BM; layer <CALayer: 0x7e95700>>"]