Appcrawler Automated Traversal usage explained (version 2.1.0)

Source: Internet
Author: User
Tags appium

Appcrawle is the auto-traversal app Crawler tool, the biggest feature is the flexibility, implementation: all clickable elements of the entire app to traverse the click. Advantages:1. Support Android and iOS, support the real machine and simulator 2. The rules for traversal can be set by configuration (such as setting blacklist and whitelist, increasing the coverage of traversal) 3. Its own traversal depth coverage, such as it has the application of the DOM tree, according to each activity under the clickable elements click, more regularity than monkey, More comprehensive coverage 4. The generated report comes with an accurate view of which elements and results are clicked, and the crash class is clearly positioned Disadvantages:1. Only one page can be located, for the page can not be slipped and then click, resulting in the following content cannot traverse (need to set their own down and then turn the page) 2. For calls to third-party applications that are less stable, such as stopping traversing 3 every time you upload an avatar. For the entire layout area is clickable, But one of the elements is not clickable, no traversal clicks, such as: the upper-left corner of the settings and the upper-right corner of the private messages can not traverse to 4. For H5 page can not be accurate positioning Click, such as its entire layout is a large module, can not be clicked (Opportunity page, financing Express, new product optimization) I. Setting up the Environment: (If you have a Java environment, of course)1.appcrawler of the latest jar package (the latest features, high compatibility), I use Appcrawler-2.1.0.jar, as follows: Baidu network disk: Https://pan.baidu.com/s/1bpmR3eJ2. Appium, used to open the session service and locate elements, you can also use the Appium GUI (desktop version), but I used to run half of the crash, memory is not enough, so we recommend the command line version of the download method: (1) Execute NPM--registry http at the command line ://registry.cnpmjs.org install-g Appium (recommended for this, NPM's domestic image) (2) Check that the required environment for Appium is OK (this step is important): Go to cmd command line, enter Appium-doctor The display is normal and succeeds 3. The Android SDK is primarily intended to use the Uiautomatorviewer.bat under the Tools folder to locate elements, get XPath for the elements, and prepare for pre-work. Two. Perform the steps:1. Mobile phone installation of the latest installation package, do not need to login (to avoid the landing before the page content, and log in and then traverse the activity will appear inconsistent error, that is, and launchactivity inconsistent) 2. Turn on the Appium service enter on the command line: Appium, Tip: Turn on success 3. Execute the following command under the folder where Appcrawler-2.1.0.jar is placed: Java-jar appcrawler-2.1.0.jar-a jingdata.apk-c config.yml--output wyy/ You can automatically start the app, and automatically traverse the click Element because the depth of the traversal is relatively large, in the coverage of the more comprehensive conditions, my side of the test will have 496 cases around, basic to run about 1 hours. The final automatically generated reports are as follows: three. How to write the configuration file Config.yml (this is the core of the operation)Parameter description: Java-jar Appcrawler-2.1.0.jar used to start appcrawler-a followed by the name of the installation package (for use when the package is not installed on your phone)-C followed by the path and name of the custom configuration file-output After the report with the output of the folder, if not written, it will automatically generate a time for the folder name of the report file actually the point here is how to write the configuration file:The configuration file is basically in key-value format, so you can use a text editor and then rename the. yml or. json file. Let's go first. My configuration file config.yml:
---logLevel: "TRACE" Reporttitle: "Jingdata" #指生成的HTML (index.html) Reports header information Savescreen:true screenshottimeout: 20currentDriver: "Android" showcancel:truetaglimitmax:5taglimit:-XPath://*[. /*[@selected = ' true ']] Count:12maxtime:10800resultdir: "" #结果文件夹名, given, will not be dynamically named Capability:newcommandtimeout:120 Launc  htimeout:120000 platformversion: "" PlatformName: "Android" Autowebview: "false" AutoLaunch: "true" NoReset: "true" Androidinstalltimeout:180000androidcapability:devicename: "" Apppackage: "Com.android36kr.investment" appactivity : "" #写不写无所谓, because the app will automatically determine whether the current activity is correct, is not launchactivity, if not the error dontstopapponreset:true app: "" Appium: "http://127 .0.0.1:4723/wd/hub "# Automationname:uiautomator2 Automationname:uiautomator2 reuse:3 headFirst:trueenterWebView:tr ueurlblacklist:-//*[contains (@resource-id, "Tv_setting_logout") and @clickable = ' true '] #登出-//*[contains (@ Resource-id, "Toolbar_close") and @clickable = ' true '] # Close button, otherwise you will fall into a dead loop and traverse the same page all the time-//*[cOntains (@resource-id, "Login_36kr_forgot_pass") and @clickable = ' true '] # forget the password and avoid logging in by traversing order-//*[contains (@ Resource-id, "Mine_info_icon") and @clickable = ' true] # My profile picture section settings are not clickable (it ends every time you run here)-//*[contains (@resource-id, "tv_  Name ") and @clickable = ' true] #头部卡片 name-//*[contains (@resource-id," Tv_company_name ") and @clickable = ' true] # Head card company and position- *[contains (@resource-id, "Company_avatar") and @clickable = ' true] # header is forbidden to enter my profile page-//*[contains (@resource-id, "Chat_ Invest_card_rl ") and @clickable = ' true] # Chat page Item header, avoid and enter the details page, jump out of the loop-//*[contains (@resource-id," Chat_send_contact_ll ") and @clickable = ' true ' #聊天详情页, exchange business cards, avoid traversing line packets when interacting with the online user-//*[contains (@resource-id, "Ll_header") and @clickable = ' true] #   My profile picture part of the entire head area, because a click on the avatar after evoking the camera will not run urlwhitelist:-//*[contains (@resource-id, "Login_36kr_ll") and @clickable = ' true ') #必须遍历账号密码登录的按钮 (in this way to log on successfully)-//*[contains (@resource-id, "fl_msg") and @clickable = ' true '] #右上角的私信按钮-//*[contains (@ Resource-id, "iv_setting") and @clickable = ' true '] # upper left corner of the settings button backbutton:-//*[contains (@resource-id, "Toolbar_back") and @clickable = ' true ']triggeractions: # primarily resolves login issues and when you encounter a login input box, enter the content , better than testcase-action: "1771019****" XPath: "//*[@resource-id= ' Com.android36kr.investment:id/login_36kr_phone_edit '] "times:1-action:" 123456 "XPath:"//*[@resource-id= ' Com.android36kr.investment:id/login_36kr_pass_code '] "times: 1-action: "Click" XPath: "//*[@resource-id= ' com.android36kr.investment:id/login_36kr_go_btn ']" times:1-action: "SWI PE ("Down") "XPath:"//*[@resource-id= ' com.android36kr.investment:id/share '] "times:1 startupactions:-Swipe (" left ")  -println (Driver) testcase:name:swipeTest steps:-When:xpath://*[contains (@resource-id, ' share ')] action: Driver.swipe (0.5,0.8,0.5,0.2) Then: []
There are some other parameters that are described below:
1, Java-jar Appcrawler-2.1.0.jar--capability apppackage=xxxxxx,appactivity=xxxxxx2, Appium--session-override:4:10,  Profile Description: 11:00 (see video main place) 3, configuration file use: True and false is the meaning of turn on and off LogLevel: Log level Savescreen: Whether Reporttitle: report name  Screenshottimeout: Screen timeout time currentdriver: Current device (Android/ios) Resultdir: Result folder name, given, will not dynamically name Taglimitmax:ios element tag control Taglimit: To tag maxtime: Maximum run time Showcancel: should be control whether to show comments capability: for configuring Appium androidcapability:android exclusive configuration,  and capability Merge Ioscapability:ios exclusive configuration urlwhitelist/blacklist: Whitelist/blacklist xpathattributes: Used to set which types of controls can be used to locate the control  Defineurl: Used to determine the URL of the element positioning XPath his text will be taken out as a URL factor (not understood) BASEURL: Set a Start URL and maxdepth to specify the initial state and traversal depth during traversal  MaxDepth: Default maximum depth 10, combined with BaseURL to control the range of traversal Appwhitelist:app white list, if jump to other apps, need to set rules, whether to allow to stay in the secondary app Headfirst: Whether it is a forward traversal or a back traverse Enterwebview: Whether to traverse the WebView control Urlblacklist:url blacklist. Used to exclude certain pages from the whitelist, the first time a whitelist has entered the range, is always on the white list.                Otherwise, you'll have to go through the white list if you don't. The upper level is a whitelist and is not currently whitelisted to return Defaultbackaction: The default return action (no example, seemingly unspecified, is click) Backbutton: Give some return controls for returning actions using FirsTList: Priority traversal of element selectedlist: The default traversal list, if not the specified type, but the control is determined, the control is clicked Lastlist: The last traversed element blacklist: excluding some controls Triggeractions: Make rules (Action, XPath, Times) Autocrawl: Auto crawl, see source specified True after run crawl (conf.maxdepth) command (crawl--empty stack start re-count Should be the main method of Appcrawler asserts: assertion, for the judgment of whether to fail testcase: test cases, see Appcrawler logs, each time it is first run the use case to go down beforeelementaction: No one seems to use  , literal meaning before the action of the element afterelementaction: the treatment with beforeelementaction is almost afterurlfinished: is also very unpopular treatment monkeyevents:monkey the number of clicks Monkeyruntimeseconds:monkey runtime given is conditional or input when is trigger condition and action then is assertion 4, one time CTRL + C generate report, two times CTRL + C is forced exit 5, terminal input Scala into Scala interpreter , enter: Q or: Quit interpreter 6, the depth of the traversal should be how to set, always jump to other pages, will not return to the current page continue to traverse, see the document through the black and white list 7, set a starting URL and maxdepth, used to specify the initial state and traversal depth during traversal

Four. What are the problems encountered? How to Solve

1. Login:Because the login page of the app is user name + verification code, because the page button is numerous and has the verification icon, need to swipe to unlock very complex, so the use of the account password login method (1) Set the account password login button for the white list, that must be clicked, at this time will be edited into the Account name password login page, The configuration is as follows: urlwhitelist:-//*[contains (@resource-id, "Login_36kr_ll") and @clickable = ' true '] #必须遍历账号密码登录的按钮 (2) Set account password login, User name and password element of the trigger, when positioned to these two elements, enter the user name and password, configured as follows: triggeractions:# mainly solve the login problem, when the login input box is encountered, the input content, better than testcase-action: "177******* "XPath:"//*[@resource-id= ' com.android36kr.investment:id/login_36kr_phone_edit '] "times:1-action:" 123456 "XPath:" *[@resource-id= ' Com.android36kr.investment:id/login_36kr_pass_code '] "times:1 (3) Set the account password login, enter the user name and password, in the order of traversal, Next there is a forgotten password click event to open a new page, in order to avoid the landing of redundant operations, the forgotten password This element is set to blacklist, do not traverse, configured as follows: urlblacklist:-//*[contains (@resource-id, "Login_ 36kr_forgot_pass ") and @clickable = ' true ']# forget password, avoid landing by traversing order 2. Chat Details pageBecause it is the online package, in order to avoid clicking on the exchange of business cards, directly send contact to the online user, so the exchange of Business Card button is set to blacklist 3. Chat Details pageThe item card of the Chat details page is clicked and re-entered into the project page, resulting in repeated traversal, so the clickable elements of the project card are set to blacklist 4. Avatar SectionClick on the avatar will be set up the camera, resulting in the operation to shutdown here, so the setting of all clickable avatar parts are blacklisted, the operation is normal. Yeah~ done, over~~ happy O (∩_∩) o~~

Appcrawler Automated Traversal usage explained (version 2.1.0)

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.