Appium Automation Testing (2)-Tools (monitor, Uiautomatorviewer)

Source: Internet
Author: User

get app Info:
   
  1. from appium import webdriver
  2. desired_caps = {}
  3. desired_caps [ ' PlatformName ' < span> = < span> ' Android ' Span class= "PLN" > # what kind of mobile platform
  4. desired_caps [ ' platformversion ' < span> = < span> ' 4.2 '   #设备版本号
  5. desired_caps [ ' devicename ' < span> = < span> Android Emulator ' &NBSP; Span class= "com" > #设备是模拟机
  6. desired_caps [ ' Apppackage ' < span> = < span> ' Com.android.calculator2 ' &NBSP; #待测试的app的java package
  7. desired_caps [ ' appactivity ' < span> = < span>   #待测试的app的activity名字
  8. Driver=Webdriver.Remote(' Http://localhost:4723/wd/hub ',Desired_caps) #
discussion: 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
1,monitor.bat(get the app's package&activity)

This tool can help us find the content-description of the Android control for future find_element_by_accessibility_id The positioning method is used for parameters.

2.Uiautomatorviewer.bat (get the app's package and control properties)

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 be used to view the apppackage of the app under test (desired capabilities).

        3. Get the activity name
1, directly see the source code, recommended; 2. Anti-compilation

If there is no code, you can decompile the app.

There will be 2 tools, Dex2jar and Jd-gui, respectively.

Take the contactmanager.apk in the toolkit as an example and briefly describe the process of anti-compilation.

  • 1, rename contactmanager.apk to Contactmanager.zip and unzip to get file Classes.dex;
  • 2. Unzip the Dex2jar-0.0.9.15.zip and enter the folder from the command line; c:\appium\ APK anti-compilation \dex2jar-0.0.9.15
  • 3, run the command d2j-dex2jar.bat  c:\appium\apk Anti-compilation \com.meijialove.activity-1\classes.dex ,
    • 4, decompression jd-gui-0.3.6.windows.zip get file Jd-gui.exe;
    • 5, open Classes-dex2jar.jar with Jd-gui.exe;

3, check log, found in the Android Devices monitor log can see the name of the activity           




























From for notes (Wiz)

Appium Automation Testing (2)-Tools (monitor, Uiautomatorviewer)

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.