To query objects you’ll need to navigate to the folder containing your apk file in the command prompt.
Run the following commands.
$ calabash-android console [apk_file] |
Type the following in IRB
$ start_test_server_in_background |
Querying allows you to view objects within your app. The format goes as followed:
query(uiquery, *args)
Examples:
query(‘*’) view all objects
query(“ImageView”) view all image objects
query(“Button index:1”) view the button with the index value of 1
To view all the query command visit: https://github.com/calabash/calabash-android/wiki/05-Query-Syntax
https://github.com/calabash/calabash-android/blob/master/documentation/ruby_api.md
The output you get when your query is a Ruby hash. You can find information to identify elements such as index value, is, and text. This query corresponds to the app screen above. The title contains the text “Notes” and is the third element on the screen.
When you query your app again you can see any new items on the screen. The text “Add note” will appear in your results if you query all the elements.
When you add any dynamic element to your app the query will show the changes. This will be used for our validations. Create a new note and add your own text. You should see the changes in IRB.
0 Comments