Appium installation and simple use

Source: Internet
Author: User
Tags install django pip install django appium

Install Appium client:
CMD under input command: Pip install appium-python-client

Pycharm Next Simple example, open calculator---Calculate 5+6=?-> off calculator with Appium drive Android emulator
From Appium import Webdriver

Desired_caps = {}
desired_caps[' platformname ' = ' Android '
desired_caps[' platformversion ' = ' 6.0 '
desired_caps[' devicename ' = ' Android Emulator '
desired_caps[' apppackage '] = ' com.android.deskclock '
desired_caps[' appactivity '] = '. Deskclock '

Driver = Webdriver. Remote (' Http://localhost:4723/wd/hub ', desired_caps) #启动app

Driver.find_element_by_name ("5"). Click ()

Driver.find_element_by_name ("+"). Click ()

Driver.find_element_by_name ("6"). Click ()

Driver.find_element_by_name ("="). Click ()

Driver.quit ()

Webdriver. Remote is actually a subclass of the native Webdriver, and the first parameter of the remote () constructor needs to display the port that the specified Appium server listens on
PlatformName: which mobile platform to use. IOS, Android, or Firefoxos
DeviceName: Which device is started, is it a real machine or an emulator? iphone Simulator, IPad Simulator, iphone Retina 4-inch, Android Emulator, Galaxy S4, etc ...
Appactivity: The activity name of the app to be tested. Like Mainactivity,. Settings. Note that the native app should add a "." Before the activity.
Apppackage: The Java package for the app to be tested. Like Com.example.android.myApp, Com.android.settings.

Other:
App: Absolute path of application, note must be absolute path. If you specify Apppackage and Appactivity, this property is not set. In addition, this property and the Browsername attribute are conflicting.
Browsername: The name of the mobile browser. such as Safari ' for IOS and ' Chrome ', ' Chromium ', or ' Browser ' for Android, and app properties are mutually exclusive.
UDID: The ID of the physical machine. Like 1ae203187fc012g.



Monitor.bat:
The file is located below Your_andriod_sdk_path\tools, can help us find the Android control Content-description, for the future find_element_by_accessibility_id Positioning method to do parameter use
Uiautomatorviewer.bat:
The file is located under Your_andriod_sdk_path\tools
This tool is primarily used to view the properties of a control, such as resource Id,class name.
The tool can also view the apppackage of the app under test (used in desired capabilities)

Find Appactivity and Apppackage:
A. Launch the apk you want to test
b, turn on the log output: adb logcat>d:/log.txt
C, turn off the log output: Ctrl + C
D. View Logs
Find:
Displayed Com.mm.android.hsy/.ui. Loginactivity: +3s859ms
Apppackage = Com.mm.android.hsy
appactivity =. UI. Loginactivity


Python article
el = Self.driver.find_element_by_android_uiautomator (' New Uiselector (). Description ("Animation") ')
Self.assertisnotnone (EL)
Els = Self.driver.find_elements_by_android_uiautomator (' New Uiselector (). Clickable (true) ')
Self.assertisinstance (Els, list)

el = self.driver.find_element_by_accessibility_id (' Animation ')
Self.assertisnotnone (EL)
Els = self.driver.find_elements_by_accessibility_id (' Animation ')
Self.assertisinstance (Els, list)
In general, it's increased in the driver.
find_element_by_accessibility_id
find_elements_by_accessibility_id
Find_element_by_android_uiautomator
Find_element_by_android_uiautomator
and other methods


Appium Connecting the real machine
1) Turn on the phone's USB debug mode
Different phones have different ways of turning on debug mode. Usually open in developer mode in Settings
2) mobile phone connection computer
Connect your phone to your computer using a data cable, then enter the ADB devices in CMD to see if the connection is successful
Novice may have two questions
The first is that the prompt is not an internal command or an external command when you enter the ADB command


Then you need to download an ADB toolkit and store it in the C:\Windows\System32 directory (it must be emphasized: consistent with the ADB Toolkit version in the SDK!!!! )


Second, the need to open the phone's USB debugging mode and install the driver
Then enter the ADB devices prompt in cmd if it succeeds


3) Start Appium service
In the cmd command, enter: Appium


Startup success

Or Appium on the configuration:

Install Django, version 1.9, install with pip install django==1.9 command

Appium installation and simple use

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.