Appium+robotframework automated testing for Android applications-6: A simple example

Source: Internet
Author: User

Everything has, only owe code!

Here's a simple example that verifies the success of adding contacts to the Address book that comes with your Android phone. This example is Appium's own example, interested students can also download their own research and study,: Sample code download

First, look at the code for the Resource.txt file:

 *** Settings ***library appiumlibrary*** Variables ***${remote_url} http:            Localhost:4723/wd/hub${platform_name} android${platform_version} 4.4.4${device_name} Android Emulator${APP} .. /.. /.. /sample-code/apps/contactmanager/contactmanager.apk*** Keywords ***add New Contact [Arguments] ${contact_name} ${ Contact_phone} ${contact_email} Open application ${remote_url} ${platform_name} ${platform_version} ${DE Vice_name} ${app} Click Element accessibility_id=add contact Input Text Id=com.example.android.contactmanag Er:id/contactnameedittext ${contact_name} Input Text Id=com.example.android.contactmanager:id/contactphoneedittex    T ${contact_phone} Input Text id=com.example.android.contactmanager:id/contactemailedittext ${contact_email} Click Element accessibility_id=save  

The emphasis here is on the five variables under variables, which are parameters of the open application keyword that are used to provide Appium-related parameter settings when the test is executed, the previous article Appium+robotframework automated testing for Android applications -2:windows launch Appium and simulator once said can not set, set in the test script, these five are the parameters of the relevant settings. The explanations below are explained separately.

${remote_url}: Remote URL, refers to the address of the Appium and the port number, after the/wd/hub is a fixed format, please do not change.

${platform_name}: Platform name, we test in Android, can only write Android.

${platform_version}: Platform version, which is the version number of Android, which is the same as the version set in the simulator.

${device_name}: The device name is the name of the emulator that is running, and if you do not know it, you can get it by entering the ADB devices command on the line.

${app}: The full path of the app to be tested, note that this path refers to the path of the machine relative to Appium, where the app needs to be downloaded from the Appium website: sample code download, download after sample-code\apps\ CONTACTMANAGER.APK can be found under the Contactmanager directory.

The next keywords is simple, you can open appiumlibrary know the specific meaning of each keyword, you can also more directly in the ride to see the meaning of the keyword, click on the top left of the K icon, and then pop up the search keywords window, Then select Source as Appiumlibrary, as shown in.

How to get elements in previous articles appium+robotframework implementing automated tests for Android apps-3: An essential tool introduction said, how about it? Isn't it easy to write?

Now let's look at the script inside Contacts.txt:

Settings ***resource          test_android_contact_resource.txt*** test Cases ***add_contact    [documentation]    Demo for Android_contacts (https://github.com/appium/sample-code/blob/master/sample-code/examples/python/ android_contacts.py)    [Tags]    demo    Add new contact    Appium User    [email protected]    5555555555    Page should contain Text    Appium User

This is even easier, call the Add new contact keyword inside the resource.txt file, the parameter is the name, mail, and phone number of the person you want to add, and the last line is to verify that the add was successful.

Well, interested friends can try it on their own.

Please continue to pay attention to ...

This article copyright to the Green Tree all, welcome reprint, but please specify the author and source, strictly prohibited for any commercial use, otherwise the consequences!

Appium+robotframework automated testing for Android applications-6: A simple example

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.