Appium Python Automation Test series Appium (iv)

Source: Internet
Author: User
Tags account security appium

? 4.1 Interface Knowledge

In the previous installation of Appium said we have two ways to install, there are two kinds of results, one is interface, one is no interface, first we first talk about the interface, and what the interface has.

First look at the first picture, if you are Windows then the interface should be like this, so you find that you and I do not have to worry about, normal. There are only 7 buttons in the entire interface of Windows, and I will speak from left to right in order from top to bottom. (Mac will have a certain difference, but not very big, just typography and style problems, but the same functionality.) )

Android Settings: The first button on the left, mainly to configure the relevant settings of Android, he inside the structure of the diagram we look at the next picture

Application path: Select the path and select the one that the app needs to test to store in this computer. When you start Appium, he will default to the path to find the app, and then install it on the designated phone.

Package: Previously mentioned, we have this bag of ID, we need to go through this to find the package, otherwise we install after what to identify these packages?

Launch activity: So the name of meaning, the start of the activity,activity when mentioned, we start the app to run the activity, here we fill in the first launch page activity.

Note: Here are a few things to keep in mind when we choose APK from choose each time, Appium will automatically re-sign the package, then the package name and activity name are automatically listed in the packages and activity, but there is a problem here. Each time you choose the APK after the list will have a cache reason, even if you change the APK, but the package has not changed, so that the start time has been an error, meet this situation do not worry, restart two times just fine.

Wait for activity: As in the above, it means waiting for an Activity to open, not much time spent, do understand.

Launch Device: The label under the things used relatively little, you can go to understand later.

Capabilities: Under this tab and we do the automation relationship is very big, after we do automation when how to configure the launch app and other information on the data under the tag.

Platform Name: We test the type of app, iOS choose Ios,android Choose android just fine.

Automation Name: Test engine names, we use Appium, so you can see appium at first sight, but he also has a selendroid. May see some doubts here, why Appium to choose two sets of system? Actually this should be traced back to the Android version of the problem, Android's own tool was one in the 4.2 version, but it was updated later, and it may be because of this reason that appium only used two sets, so when you test the app to install the machine in the 4.0 or earlier version then the engine here you have to choose selendroid, whether so everyone can go Give it a try. The only standard for testing truth is to try it yourself.

Platform version: Installs the app phone's release number, Android is a few versions.

Device Name:

Note: There will be a problem, if you test Android, only a phone inserted into the computer, even if you enter the device name is wrong, but you can still install, use. But iOS is not a good way to go. Do not know whether in the design of the time is such a consideration, if you encounter similar problems in the later use do not panic.

Advanced label things in the initial stage do not worry, this tag is only when you want the same computer to control multiple phones at the same time to use, you need to change the port number bootstrap port, remember this is good.

General Setting:

In general setting we use the default settings as usual, but there are some basic settings that can be adjusted to facilitate later learning. The entire page is divided into two parts: server and log, the default is the following image.

Server Address: Configure the Appium service addresses, normally we do not need to change, but if we need to configure more than one phone to start a number of appium services, then the port number here we need to adjust, if you have more than the same port will be error.

Override Existing Session:session coverage, perhaps for beginners do not understand what is called the session, you here temporarily understood as the conversation, I and your session's unique indicator.

Log to File: The default state is that there is no data, but it is recommended to do automation, because the log generated by Appium at run time will persist to the problem you set, which is very helpful for the post-bug location. Remember!

Developer settings (the third button on the left) are rarely used and can be ignored. If you are interested, you can look at it as an interest.

About (the fourth button on the left), view the version information for the current appium.

Element detection (second button on the right): The function of this button is similar to the Firebug positioning tool, but he also has a function that will detect whether your system configuration is correct, and if the previous parameters are incorrect, use this function to make an error. If you don't connect your phone properly. It is recommended to use the uiautomatorviewer that comes with the SDK tool.

Start the service (the first button on the right): all the parameters you need to do is to start the Appium service, and you will be able to automate it only after it has been started.

Clear log (bottom right corner): In the script, debugging process will generate a lot of logs, but you may want to see only the middle of a certain period of time, then you can at this time to clear the page log.

4.2 Log Analysis

With the previous study plus hands-on practice I believe many small partners will be able to start the appium, and will automatically install the app to the phone or simulator, but this time many people see Appium panel or console will be more headache. Appium Service page constantly in the rolling log, but can not understand, this may be a common problem. Below we analyze this log, we are about to interpret this log, let oneself no longer confused. I'll configure the interpretation on each line to make it easier for everyone to understand.

I started the Appium service and specified the IP, port, and my UID

192:~ ytxu$ appium-a 127.0.0.1-p 4723-u 127.0.0.1:62001

Startup success

[Appium] Welcome to Appium v1.6.3

[Appium] Non-default Server args:

Service address after the successful start

[Appium] Address: ' 127.0.0.1 '

Our UID because I'm here is the link simulator so with this IP

[Appium] Udid: ' 127.0.0.1:62001 '

[Appium] Deprecated Server args:

The system is automatically stitched into a dictionary form

[Appium]-u,--udid =--default-capabilities ' {"Udid": "127.0.0.1:62001"} '

[Appium] Default capabilities, which'll is added to each request unless overridden by desired capabilities:

[Appium] Udid: ' 127.0.0.1:62001 '

Which port is being monitored by the REST HTTP interface

[Appium] Appium REST HTTP Interface listener started on 127.0.0.1:4723

A session is created by post, and the value in this session is the data we have when we configure the app, where the system automatically converts it into a dictionary form, and a key corresponds to a value. If you look carefully, you will find that you are not unfamiliar.

[HTTP]-post/wd/hub/session {"requiredcapabilities": {}, "Desiredcapabilities": {"devicename": "127.0.0.1:62001 "," app ":"/users/ytxu/desktop/appiumpython/apps/mukewang.apk "," AutoLaunch ":" true "," Platformversion ":" 4.1 "," Apppackage ":" Cn.com.open.mooc "," PlatformName ":" Android "," appactivity ":" Cn.com.open.mooc.index.splash.MCSplashActivity "}}

[Debug] [MJSONWP] Calling Appiumdriver.createsession () with args: [{"DeviceName": "127.0.0.1:62001", "app": "/users/ytxu/desktop/ appiumpython/apps/mukewang.apk "," AutoLaunch ":" true "," Platformversion ":" 4.1 "," Apppackage ":" Cn.com.open.mooc "," PlatformName ":" Android "," appactivity ":" Cn.com.open.mooc.index.splash.MCSplashActivity "},{},null,null,null]

Create a session, prepare to start a conversation, put the data that was filled in, pass in the data, authenticate with the server, and if successful, start the session.

[Appium] Creating New Androiddriver Session

[Appium] Capabilities:

[Appium] devicename: ' 127.0.0.1:62001 '

[Appium] App: '/users/ytxu/desktop/appiumpython/apps/mukewang.apk '

[Appium] AutoLaunch: ' True '

[Appium] platformversion: ' 4.1 '

[Appium] apppackage: ' Cn.com.open.mooc '

[Appium] PlatformName: ' Android '

[Appium] appactivity: ' cn.com.open.mooc.index.splash.MCSplashActivity '

[Appium] Udid: ' 127.0.0.1:62001 '

[Debug] [Androiddriver] Androiddriver version:1.10.38

Do you still find it troublesome to see this place? As long as you look carefully you will be easy to understand. Maybe there will be a small partner to say that the start is very easy, but the actual problem encountered is not so easy, then we look at a real problem encountered, directly read the log:

Debug] [ADB] We tried to start a activity that doesn ' t exist, retrying with. prepended to activity

[Debug] [ADB] Device API level:19

[Debug] [ADB] Getting Connected devices ...

[Debug] [ADB] 1 device (s) connected

[Debug] [ADB] Running '/users/ytxu/library/android/sdk/platform-tools/adb ' with args: ["-P", 5037, "-S", "127.0.0.1:62001", "Shell", "AM", "Start", "-w", "-N", "Cn.com.open.mooc/.cn.com.open.mooc.aindex.splash.mcsplashactivity", "-S", "-a", " Android.intent.action.MAIN ","-C "," Android.intent.category.LAUNCHER ","-F "," 0x10200000 "]

[ADB] Error:activity used to start app doesn ' t exist or cannot be launched! Make sure it exists and is a launchable activity

At Object.wrappedLogger.errorAndThrow (lib/logger.js:60:13)

At adb.callee$0$0$ (.. /.. /.. /LIB/TOOLS/APK-UTILS.JS:68:13)

At TryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)

At Generatorfunctionprototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/ REGENERATOR/RUNTIME.JS:315:22)

At Generatorfunctionprototype.prototype. (anonymous function) [As Next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)

At Generatorfunctionprototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/ RUNTIME.JS:136:37)

Error:activity used to start app doesn ' t exist or cannot be launched! Make sure it exists and is a launchable activity

At Object.wrappedLogger.errorAndThrow (lib/logger.js:60:13)

At adb.callee$0$0$ (.. /.. /.. /LIB/TOOLS/APK-UTILS.JS:68:13)

At TryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)

At Generatorfunctionprototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/ REGENERATOR/RUNTIME.JS:315:22)

At Generatorfunctionprototype.prototype. (anonymous function) [As Next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)

At Generatorfunctionprototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/ RUNTIME.JS:136:37)

[ADB] Error:error occured while starting app. Original Error:activity used to start app doesn ' t exist or cannot be launched! Make sure it exists and is a launchable activity

At Object.wrappedLogger.errorAndThrow (lib/logger.js:60:13)

At adb.callee$0$0$ (.. /.. /.. /lib/tools/apk-utils.js:80:9)

At TryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)

At Generatorfunctionprototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/ REGENERATOR/RUNTIME.JS:315:22)

At Generatorfunctionprototype.prototype. (anonymous function) [As Next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)

At Generatorfunctionprototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/ RUNTIME.JS:136:37)

Error:error occured while starting app. Original Error:activity used to start app doesn ' t exist or cannot be launched! Make sure it exists and is a launchable activity

At Object.wrappedLogger.errorAndThrow (lib/logger.js:60:13)

From the first sight of this log I know everyone's first reaction has fainted, nothing we have to look carefully. In the first line of the log, the approximate meaning is "we tried to run the activity, but he still didn't exist." "Then see here the little buddy should think about a problem, when the previous configuration page said that if you configure the package or the activity error is not bootable. Now we've been told that this activity doesn't exist. Should we go over it?

In fact, in the whole log we should go directly to the Error section, [ADB] error:activity used to start app doesn ' t exist or cannot be launched! Make sure it exists and is a launchable activity, this is the log of error, given the hint is also this activity can not be started, let you reconfirm and then go to boot.

From this little experiment we can see the log itself is not difficult, the difficult is we did not look carefully. So after meeting the problem don't fret, should look at the log carefully, and then solve the problem.

How the 4.3 appium works

When we are familiar with a set of systems or frameworks, we want to learn, do we have to understand how it works? It is only after we know how he works that we can solve the problem from the root when we meet the difficult problems in the future. But before you talk about this, you need to say a digression and wonder who has thought about how appium is automated? Whether iOS or Android in the automation to take into account security factors such as they are not allowed to operate directly, so we have to do automation then must rely on their own published tools, Android is Uiautomator, iOS uses uiautomation, in fact what we call automation is the tool that we use to invoke the framework that they publish and then execute it. Let's take a look at how Appium works, first look at a picture.

With the image above we can see that Appium is based on the Webdriver protocol, and he uses Bootstrap to invoke Google's published Android automated test framework Uiautomator commands to implement our app automation, One more thing to understand is that we run the automated test script on our computer (client), call the Webdriver interface, Appium server receives the command sent over our client, and he converts these commands into commands uiautomator know. The automation is then performed by Uiautomator.

Maybe some of the little friends here will be confused, saying that Android is so so is iOS? Actually pretty much, just the tools they support are different, iOS is using uiautomation, first the client sends the script request, then to our Appium service, here Appium will call instruments to start a server, Then let him do the following to complete the automation. Note: UIAutomation is a tool under instruments, so don't panic.

Advantages of 4.4 Appium

Now on the market to do the framework of automation, whether mature or general have a lot of, we can not all familiar, but we need to understand a common, otherwise how do you know good and bad? I believe that in the study of automation, I thought about why need to learn appium, in fact, I just started to do mobile automation when the choice is robotium, but later because the project needs to find me if I just use Robotium find iOS simply can't do, then I need to do one alone, this will be very troublesome , this time Appium just came out, just contact him I decided to use, because in the previous web automation used is selenium, so this will be very convenient to use. Let's take a look at some of his strengths:

1, can support both Android, iOS

2. Support multiple languages, Java, Python, PHP, Ruby, etc.

3. No need to worry about complex environment

4. If you have selenium experience, get started directly

From the above to see his merits or a lot of, of course, there are shortcomings, not listed here, lest spoil the good impression.

When you see this, do you have a vague shadow of Appium? The next thing we need is to do the actual combat.

Appium Python Automation Test series Appium (iv)

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.