In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "what are the knowledge points of the Appium framework". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn what are the knowledge points of the Appium framework.
1. Test object
Appium is an open source tool for automating native, mobile Web, and hybrid applications on iOS, Android devices, and Windows desktop platforms.
Native applications refer to those written in iOS, Android, or WindowsSDK.
Mobile web Apps are applications accessed by mobile browsers (Appium supports built-in browsers on Safari, Chrome and Android on iOS).
Hybrid applications comes with a "webview" wrapper-native controls for interacting with Web content.
The important thing is that Appium is cross-platform: it allows you to write tests on multiple platforms with the same API, reusing code between iOS, Android, and Windows test suites.
2. Support platform and language
● appium is cross-platform and supports OSX,Windows and Linux systems. It allows testers to write automated test scripts using the same set of API on different platforms (iOS,Android), which greatly increases the reusability of code between iOS and Android test suites
● appium supports multiple languages and adopts the Cramp S design pattern, as long as client is able to send http requests to server.
3. Working principle
Working principle of APPIUM IOS end
Let's take a look at the working principle of the whole process of APPIUM on iOS through a picture:
Working principle of APPIUM Android end
Let's take a look at the whole process of Android APPIUM through a picture:
Explanation:
The entire arrow points to a completed instruction loop
Webdriver script requires automated testers to write their own test scripts.
I suggest you learn about JSON wire protocol, instruments and UiAutomator.
4. Installation tools
● test languages, such as python
● appium client
● appium server
● mobile devices, which need to be installed if using a virtual machine
5. Environment building
(1) install Android SDK
1. Android SDK (Software Development Kit, Software Development Kit) provides Android API libraries and development tools to build, test and debug applications, which can be seen as a software for developing and running Android applications.
2. Provide gadgets, such as adb, aapt, uiautomatorview
3. The test equipment uses an Android simulator, which must not be skipped.
(2) install appium Server
1. Appium official website: https://pium.app/downloads/
2. Download the appium installation package (AppiumForWindows.zip,appium.dmg)
3. Install and configure the appium environment variable
(3) install python-client
1. Install programming languages, such as python
2. If you install Appium-Client,python, you can use pip to install: pip install Appium-Python-Client
6. Application and operation
① calls appium procedure
1. Configure the parameters of the mobile device and tell the server which mobile device I want to set up.
2. Grab the controls applied on the phone and specify the corresponding controls for operation
3. Operate the crawled controls, such as clicking, filling in parameters, etc.
The first step is to configure the parameters of mobile devices.
The basic configuration of Desired Capabilities for Appium is as follows:
# Android environment
Import unittest
From appium import webdriver
Desired_caps = {}
Desired_caps ['platformName'] =' Android'
Desired_caps ['platformVersion'] =' 4.2'
Desired_caps ['deviceName'] =' Android Emulator'
Desired_caps ['app'] = PATH ('.. / apps/selendroid-test-app.apk')
Desired_caps ['appPackage'] = package
Desired_caps ['appActivity'] = activity
Self.driver = webdriver.Remote ('http://localhost:4723/wd/hub', desired_caps)
Explanation of common parameters:
● deviceName: specify startup devices, such as Android Emulator, iPhone Simulator, etc.
● automationName: specifies the automation engine, default appium
● platformName: specify mobile platform, Android or iOS
● platformVersion: specifies the system version of the platform. For example, specify an Android system version of 4.2
● appActivity: the Activity of the app to be tested. Note that the native app should be preceded by a "."
● appPackage: package name (package) information of the app to be tested
The second step is to grab the controls applied on the phone.
Use the Android SDK built-in tool uiautomatorviewer.bat to view the control parameters of the mobile app (the tool is located in the / tools/bin/ directory)
1. Id positioning
How to use it:
Driver.find_element_by_id ('com.android.contacts:id/three')
2. Name positioning
How to use it:
El = self.driver.find_element_by_name ('missed calls') el = self.driver.find_elements_by_name ('missed calls')
3. Class name positioning
How to use it:
Els = self.driver.find_element_by_class_name ('android.widget.ImageButton') els = self.driver.find_elements_by_class_name (' android.widget.ImageButton')
4. Accessibility ID positioning
How to use it:
El = self.driver.find_element_by_accessibility_id ('3') el = self.driver.find_elements_by_accessibility_id ('3')
5. Android uiautomator positioning
How to use it:
El=self.driver.find_element_by_android_uiautomator ('new UiSelector (). Description (star symbol)')
Els=self.driver.find_elements_by_android_uiautomator ('new UiSelector (). Clickable (false)')
The third step is to operate the control
1.scroll
Scroll (self, origin_el, destination_el):
Scroll from element origin_el to element destination_el
For example: driver.scroll (el1, el2)
Usage: driver.scroll (el1,el2)
2.tap
Tap (self, positions, duration=None):
Simulate finger clicks (up to five fingers) to set the hold time (milliseconds)
Example: driver.tap ([(100,20), (100,60), (100,100)], 500)
Usage: driver.tap ([(xrecoery y), (x1memy1)], 500)
3. Swipe
Swipe (self, start_x, start_y, end_x, end_y, duration=None):
Slide from point A to point B, sliding time is millisecond
Example: driver.swipe (100,100,100,400)
Usage: driver.swipe (x1 ~ 1 ~ 1 ~ 2 ~ 2500)
4. Keyevent
Keyevent (self, keycode, metastate=None):
Send the key code (Android only), which can be found on the URL.
Usage: driver.keyevent ('4')
5. Press_keycode
Press_keycode (self, keycode, metastate=None):
Send the key code (Android only), which can be found on the URL.
Usage: driver.press_ keycode ('4')
6.text
Text (self):
Returns the text value of the element
Usage: element.text
7.click
Click (self):
Click on the element
Usage: element.click ()
8.get_attribute
Get_attribute (self, name):
Get the related value of an element
Usage: element.get_attribute ("name")
9.size
Size (self):
Gets the size (height and width) of the element
Usage driver.element.size
10. Page_source
Page_source (self):
Get the source of the current page
Usage: driver.page_source
11.quit
Quit (self):
Exit the script and close each related window connection
Example: driver.quit ()
Execution result judgment
When the use case is completed and you need to judge whether it is passed or not, you need to compare it with your expected results. Generally, you can choose to assert to find whether a marker bit is present, or whether the text value of an element is equal to the expected value. You can also compare screenshots with reference pictures, and so on.
At this point, I believe you have a deeper understanding of "what are the knowledge points of the Appium framework?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.