Python-uiautomator Learning & Use

Source: Internet
Author: User

First, installation

Source Address:

Https://github.com/xiaocong/uiautomator#basic-api-usages

① Download Zip package, unzip to local directory

② into the corresponding directory, execute

Command-line prompt uiautomator installation is successful, you can now start writing uiautomator scripts in Python ~ ~

Second, use

Https://github.com/xiaocong/uiautomator#basic-api-usages

The author provides explanations of all APIs that can be queried directly for use.

There is also a ppt,ppt address:

Http://xiaocong.github.io/slides/android-uiautomator-and-python/#/main

The following is the API used in the process of the specific operation of the TV, to record the ~ ~ ~

#Coding:utf-8Import Time fromUiautomatorImportdevice as Dd.press.enter () Time.sleep (5)Print(D (classname="Android.widget.FrameLayout"). Child (resourceid="Com.stv.launcher:id/metro_space"). Child_by_instance ("0", classname="Android.view.View"). Count)Print(D (classname="Android.widget.FrameLayout"). Child (resourceid="Com.stv.launcher:id/metro_space", classname="Android.support.v4.view.ViewPager"). Count)Print(D (classname="Android.widget.FrameLayout"). Child (resourceid="Com.stv.launcher:id/metro_space", classname="Android.support.v4.view.ViewPager") [0].info]Print(D (classname="Android.widget.FrameLayout"). Child (resourceid="Com.stv.launcher:id/metro_space", classname="Android.support.v4.view.ViewPager") [1].info)Print(D (classname="Android.view.View"). Count)Print(D (classname="Android.view.View") [0].info]Print(D (classname="Android.view.View") [1].info)Print(D (classname="Android.widget.FrameLayout"). Child (resourceid="Com.stv.launcher:id/metro_space"). Child (index=2). Count)Print(D (text="Hot Spotlight"). Info) d (Text="Play Record"). Click ()Print(D.exists (classname="Android.widget.FrameLayout")) D.dump ("Home.xml")Print(D (resourceid="Com.letv.android.tv.letvlive:id/title", instance=0). Text) D.click (1100,850)

Iii. problems and limitations encountered in the use of TV test

is still relatively convenient, basic UI operation can basically be covered. But the use is not enough handy.

The click operation on the 1.TV is different from the mobile phone, the phone can be directly clicked on, but the click operation on the TV is the focus of the first move, click or Pressenter to achieve clicks into the operation, but some apps on TV do not support the click Mobile Focus operation, Only support analog remote control input to move up or down;

When implemented in Java, use the following method: Simulate the remote to move up and down until the desired control is found, and then proceed. However, Python did not find the API to locate the current control focused, which could not be implemented. (Perhaps the author's original intention is only to facilitate the use of mobile phones, after all, the API also provides a lot of zoom, swipe and other operations, these operations are more suitable for mobile devices) 2. Navigate to the element and want to print out the control INFO,TV the desktop often restarts, resulting in running timeout. This problem does not occur when using Java, and is currently unable to locate Python in the process of querying the control information and display the operation of what is done or is the desktop itself bug? Pending..

Python-uiautomator Learning & 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.