Appium + Robotframework for automated testing of iOS apps-5: A simple example

Source: Internet
Author: User
Tags appium

Appium + Robotframework for automated testing of iOS apps-5: A simple example

Everything is ready. It is not encoded!

The following is a simple example to verify Common Logon functions. The application in this example is being developed by my company and has not been officially launched yet. The download path is not provided. The logon function is used by many applications. We all know what the function is.

First, check the code of the resource.txt file:

 

* ** Settings ** Library AppiumLibrary *** Variables *** $ {REMOTE_URL} http: // 192.168.1.6: 4723/wd/hub $ {PLATFORM_NAME} iOS $ {PLATFORM_VERSION} 8.3 $ {DEVICE_NAME} iPhone 5 s $ {APP}/Users/admin/xxx_ios/xxx/build/Debug-iphonesimulator /xxx. app $ {User} 138 *** 6789 $ {Password} 888888 *** Keywords *** Setup Open Application remote_url =$ {REMOTE_URL} platformName =$ {PLATFORM_NAME} platformVersion = $ {PLATFORM_VERSION} deviceName =$ {DEVICE_NAME} app =$ {APP} Short Sleep Swipe 500 200 100 200 500 # Slide Short Sleep Swipe 500 200 100 200 # Slide Short Sleep Click Element xpath = // UIAApplication [1]/UIAWindow [1]/UIAButton [1] # Click now to experience Short SleepTeardown Close All Applications
To put it simply, because Appium is used for testing, you must add AppiumLibrary to Settings and install AppiumLibrary iN OS X, for specific installation methods, refer to my previous article Appium + Robotframework to implement automated testing of Android applications-4: Introduction and installation of AppiumLibrary.

 

The parameters required to set the good luck row Appium in Variables are described as follows:

 

$ {REMOTE_URL}: remote URL, which refers to the address and port number of Appium. The/wd/hub format is fixed. Do not change it.

$ {PLATFORM_NAME}: Platform name. We tested it in iOS and can only write it in iOS.

$ {PLATFORM_VERSION}: The Platform version, that is, the iOS version. You can run commands on the OS X terminal.Xcodebuild-showsdksLearn the version number, as shown in. You can find information about the specific usage of the xcodebuild command.

$ {DEVICE_NAME}: device name. Even if it is an Apple device name, make sure it matches the version number above.

$ {APP}: full path of the App to be tested. Note that this path refers to the path relative to the machine where Appium is located, that is, the path on the machine where OS X is located, here we use the app file compiled using the xcodebuild command.

$ {User}: the User name for Logon. Because the mobile phone number is used as the logon, the complete mobile phone number is used here.

$ {Password}: Password corresponding to the login user name.

The Setup in Keywords will automatically execute the script first when the test starts. First, install and Open the Application using the Open Application keyword (if it has been installed before, it will automatically uninstall it ), then, because the application has two welcome interfaces, you need to use the Swipe keyword to slide left to enter the startup page, and then Click the "try now" button through the Click Element keyword to enter the home page.

Note that AppiumLibrary does not have a keyword for the waiting duration after the keyword is executed. Here, Short Sleep is used for the waiting time between keyword executions. The Short Sleep keyword is a custom keyword, it is actually the encapsulation of Sleep x. The specific waiting duration x can be set according to the actual situation.

Teardown will automatically execute the script after the test is completed. It is easy to call Close All Applications to Close All Applications.

Next, let's look at the specific logon verification script:

 

TestCase verify login Click Element name = login/register Short Sleep Input Value xpath = // UIAApplication [1]/UIAWindow [1]/UIATextField [1] $ {User} 1 # Input error username Input Text xpath = // UIAApplication [1]/UIAWindow [1]/UIASecureTextField [1] $ {Password} # Password Click Element name = login Page shoshould Contain Element name = login # stay at the login page Input Value xpath = // UIAApplication [1]/UIAWindow [1]/UIATextField [1] $ {User} # correct User name Input Text xpath = // UIAApplication [1 ]/UIAWindow [1]/UIASecureTextField [1] $ {Password} a # enter the incorrect Password Click Element name = log on to Page shocould Contain Element name = login # Stay On the login Page Input Value xpath = // UIAApplication [1]/UIAWindow [1]/UIATextField [1] $ {User} # correct username Input Text xpath = // UIAApplication [1]/UIAWindow [1]/ UIASecureTextField [1] $ {Password} # enter the correct Password. Click Element name = log on to Short Sleep Element Name shocould Be xpath = // UIAApplication [1]/UIAWindow [1]/UIATableView [1] ]/UIAStaticText [5] xxx # verify that the user displayed after logon is the specified user
Here, there are two negative test verifications: Enter the wrong user name and enter the wrong password to log on, and expect the result to be a logon failure, still on the logon page; followed by a positive verification, after entering the correct user name and password, you should log on successfully and display the user name. The script is very simple and will not be repeated.

 

 

Related Article

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.