Calabash-android is a unit test tool that is used to test the UI. This feature is ideal for swiping app ads. This article uses a simple example to teach you to use calabash-anroid to brush the app's ads. Code: Https://github.com/bigconvience/poker_hu
Before using the examples provided in this article to test, please ensure that the test environment is installed, you can refer to this article:Windows installation calabash-android
After the code is downloaded, go to the project directory and enter Calabash-android run as shown in:
At this point, the catalog features is created at the first edge of the project catalog. This app is a three-person bucket landlord's mini-game, click on the menu-> ad recommendation, just pop up the ad, as shown in:
In order to achieve the purpose of the Brush advertisement, add the following code in Features/my_first.feature
Feature:click ads Feature scenario:i can Click menu item to show Adsthen I wait for the ' pokeractivity ' screen to AP Pearthen I wait for ten secondsthen I press the menu Keythen I wait for 5 seconds then I touch on screen m from the l EFT and the Topthen I wait for secondsthen I go back
Since the Android version of the touch coordinates step has not yet been defined, you can add the file touch_steps.rb in the Step_definitions code as follows:
#--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
Open the Windows command line, set the command line font: CMD input:
chcp 65001
, specifically for reference: http://blog.sina.com.cn/s/blog_628e2ab30101ajcg.html
On the command line, enter: Calabash-android run poker_hu.apk to start the ad. After that, the command is encapsulated with a shell script or batch file, and the ad is automatically brushed.
Use Calabash-android to brush ads