Getting Started with calabash-android usage

Source: Internet
Author: User

This article describes how to install the Calabash-android test environment in Windows, using an example to introduce the basic usage of calabash-android.


The source generation used in this article is located in: https://github.com/bigconvience/HackerNews

Once the code is downloaded, enter the project directory and enter it at the command line: Calabash-android Gen, this command generates directory features in the project directory, such as the following directory structure:

features|_support| |_app_installation_hooks.rb| |_app_life_cycle_hooks.rb| |_env.rb| |_hooks.rb|_step_definitions| | _calabash_steps.rb|_my_first.feature

The Step_definions directory contains user-defined features, my_first.feature the steps to write the test.

Screenshot of basic usage

Write down the following code in the My_first.feature

Feature:startup Feature    scenario:i can start my app then        I wait for the seconds then I take        a screenshot
The first line represents the name of the functional test, the second line represents the scenario, the third row and the fourth behavior of the scenario: wait 15 seconds, then the screenshot.

Enter calabash-android run hacknews.apkon the command line, the application will be installed in the phone or simulator, after 15 seconds, will automatically screenshot, the picture is saved in the current project directory. You can also customize the saved path:

SCREENSHOT_PATH=/tmp/foo/ calabash-android run
To start the test in this way, the picture is saved below the directory/tmp/foo/.

Custom feature of basic usage

To create a new file touch_steps.rb in Step_definitions, add the following code:

#--Touch--#Then/^i (?:p ress|touch) on screen (\d+) from the left and (\d+) from the top$/do |x, Y|touch (nil, {: offset = = {: x = x.to_i,: y = = y.to_i}}) sleep (3) End
The custom feature will be parsed by the test framework. The function name is written in the/^ &/, the parameter list is located in | | In The code in the middle of then and end is the executed statement. Then add the code in the My_first.feature:

Then I touch on screens from the left and the top
The above code indicates a click on the ad bar in the graph


The next one will detail the built-in features in calabash-android

Getting Started with calabash-android usage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.