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 Downloadfirst, 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}.. /.. /.. /contactmanager/contactmanager.apk
- Keywords * * *
- Add New Contact
- [Arguments] ${contact_name} ${contact_phone} ${contact_email}
- Open application ${remote_url} ${platform_name} ${platform_version} ${device_name} ${app}
- Click Element Accessibility_id=add Contact
- Input Text Id=com.example.android.contactmanager:id/contactnameedittext ${contact_name}
- Input Text Id=com.example.android.contactmanager:id/contactphoneedittext ${contact_phone}
- Input Text Id=com.example.android.contactmanager:id/contactemailedittext ${contact_email}
- Click Element Accessibility_id=save
Copy CodeThe key here is to say the variables under the five variables, they are open application keyword parameters, used in the test execution to provide appium related parameter settings, the previous article once said can not be set, in the test script to set up, These five are the parameters that make 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 the previous article said, how? Isn't it easy to write? Now let's look at the script inside Contacts.txt:
- Settings * * *
- Resource 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
Copy CodeThis 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. transferred from: http://bbs.51testing.com/thread-1052147-1-1.html
Appium+robotframework automated testing for Android applications-6: A simple example