Appcrawler配置与使用教程
(常见问题在文章末尾处)
一、环境准备
1.jdk
网址:https://www.oracle.com/java/technologies/downloads/?er=221886#java8
环境变量配置:
然后在path
中添加:
%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;
cmd输入:
Java -version
。显示jdk版本就是成功了
2.Android SDK
(脚本适配的同学可能配置过部分,建议按照这个步骤再来一次)
网址:https://www.androiddevtools.cn/
下载好后安装(直接next到最后一步):
安装完成后会自动打开 SDK Manage.exe(或手动在安装目录下找到 SDK Manage.exe 双击打开)。选择需要安装的api版本和对应的工具,这些在运行模拟器和真机测试的时候会使用到。
已经自动选好要安装的包了,直接点右下角 install
然后会到 License,点击三个地方并 Accept:
变成上面那样后就可以进行下载了。
之后配置环境变量:(脚本适配的同学可能配置过部分,再检查一下)
//新建 ANDROID_HOME环境变量
ANDROID_HOME = E:\Android\sdk
//在path变量边增加以下值
%ANDROID_HOME%\platform-tools
%ANDROID_HOME%\tools
%ANDROID_HOME%\build-tools\29.0.3
打开命令行输入:
adb version
显示如上就是安装成功。
*3.appium安装(先省略,直接到4)
网址:https://bitbucket.org/appium/appium.app/downloads/
解压运行exe文件,全部点击下一步即可(安装可能需要等待一些时间)
配置appium环境:
在系统变量的 path 中添加:
在命令行中输入 appium-doctor:
4.Node.js
直接下载安装:
安装完成以后,检查Node版本安装是否成功:进入CMD,输入node -v, 可以看到版本号,说明成功了。
5.Appium Server
cmd中输入 npm install -g appium
6.Appium Server GUI
网址:https://github.com/appium/appium-desktop/releases
下载安装好后启动:
appium的端口一般是默认4723,如上填写,然后点击startServer ,进入后界面如下:
7.Maven
网址:https://maven.apache.org/download.cgi
下载之后解压到一个路径 p,打开环境变量,新建系统变量。
变量名为:
MAVEN_HOME
。值为 p。
之后在系统变量的 path 变量里面新建:
%MAVEN_HOME%\bin
配置好后在 cmd 中输入 mvn -v:
二、使用AppCrawler
AppCrawler 项目GitHub地址:https://github.com/seveniruby/AppCrawler
- 复制 GitHub 该项目url:
- 在本地目录新建一个文件夹(AC),打开cmd准备克隆源码: 输入
git clone https://github.com/seveniruby/AppCrawler.git
(可能因为网不好一直在这一步断开,多执行几次)
直到:
3. 在 打开cmd,输入
git checkout 2.3.1
切换到分支:
3. 执行
mvn assembly:single
命令进行编译
4. 启动
appium
(见常见问题4)
5. 输入
adb devices
确保设备连接上了
6. 修改配置文件 demo.yaml:
app:时钟
package:com.android.deskclock
activity:com.android.deskclock/com.android.deskclock.DeskClockTabActivity
- 输入
java -jar appcrawler.jar -c demo.yaml
(这里需要 appcrawler.jar 和 demo.yaml) 执行后会生成类似如下文件夹: 文件夹内有执行的截图和日志。
三、常见问题及注意事项
1. 双击“SDK Manager.exe”一直闪退
打开tools/android.bat文件修改内容如下:
@echo off
rem Copyright (C) 2007 The Android Open Source Project
rem
rem Licensed under the Apache License, Version 2.0 (the "License");
rem you may not use this file except in compliance with the License.
rem You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.
rem Useful links:
rem Command-line reference:
rem http://technet.microsoft.com/en-us/library/bb490890.aspx
rem don't modify the caller's environment
setlocal enableextensions
rem Set up prog to be the path of this script, including following symlinks,
rem and set up progdir to be the fully-qualified pathname of its directory.
set prog=%~f0
rem Grab current directory before we change it
set work_dir=%cd%
rem Change current directory and drive to where the script is, to avoid
rem issues with directories containing whitespaces.
cd /d %~dp0
rem Check we have a valid Java.exe in the path.
rem 原来的内容如下
rem set java_exe=
rem call lib\find_java.bat
rem if not defined java_exe goto :EOF
rem 修改为:
set java_exe=D:\Program Files\Java\jdk-1.8\bin\java.exe
rem D:\Program Files\Java\jdk-1.8\bin\java.exe 为java的路径
set jar_path=lib\sdkmanager.jar;lib\swtmenubar.jar
rem Set SWT.Jar path based on current architecture (x86 or x86_64)
for /f "delims=" %%a in ('"%java_exe%" -jar lib\archquery.jar') do set swt_path=lib\%%a
:MkTempCopy
rem Copy android.bat and its required libs to a temp dir.
rem This avoids locking the tool dir in case the user is trying to update it.
set tmp_dir=%TEMP%\temp-android-tool
xcopy "%swt_path%" "%tmp_dir%\%swt_path%" /I /E /C /G /R /Y /Q > nul
copy /B /D /Y lib\common.jar "%tmp_dir%\lib\" > nul
copy /B /D /Y lib\commons-codec* "%tmp_dir%\lib\" > nul
copy /B /D /Y lib\commons-compress* "%tmp_dir%\lib\" > nul
copy /B /D /Y lib\commons-logging* "%tmp_dir%\lib\" > nul
copy /B /D /Y lib\dvlib.jar "%tmp_dir%\lib\" > nul
copy /B /D /Y lib\gson* "%tmp_dir%\lib\" > nul
copy /B /D /Y lib\guava* "%tmp_dir%\lib\" > nul
copy /B /D /Y lib\httpclient* "%tmp_dir%\lib\" > nul
copy /B /D /Y lib\httpcore* "%tmp_dir%\lib\" > nul
copy /B /D /Y lib\httpmime* "%tmp_dir%\lib\" > nul
copy /B /D /Y lib\layoutlib-api.jar "%tmp_dir%\lib\" > nul
copy /B /D /Y lib\org-eclipse-* "%tmp_dir%\lib\" > nul
copy /B /D /Y lib\sdk* "%tmp_dir%\lib\" > nul
copy /B /D /Y lib\swtmenubar.jar "%tmp_dir%\lib\" > nul
rem jar_path and swt_path are relative to PWD so we don't need to adjust them, just change dirs.
set tools_dir=%cd%
cd /d "%tmp_dir%"
:EndTempCopy
rem The global ANDROID_SWT always override the SWT.Jar path
if defined ANDROID_SWT set swt_path=%ANDROID_SWT%
if exist "%swt_path%" goto SetPath
echo ERROR: SWT folder '%swt_path%' does not exist.
echo Please set ANDROID_SWT to point to the folder containing swt.jar for your platform.
goto :EOF
:SetPath
rem Finally exec the java program and end here.
REM set REMOTE_DEBUG=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
call "%java_exe% %REMOTE_DEBUG%" "-Dcom.android.sdkmanager.toolsdir=%tools_dir%" "-Dcom.android.sdkmanager.workdir=%work_dir%" -classpath "%jar_path%;%swt_path%\swt.jar" com.android.sdkmanager.Main %*
rem EOF
2.环境变量的配置
配置环境变量的时候看清楚是 添加系统变量(要输入变量名和变量值的那个),还是在系统变量中的path中新建(一般是跟在前者之后,加%的)。并且配置好后要连续点击好几个确定。
3. 输入 appium 报错缺插件:
输入
appium plugin list
查看插件列表:
把没有 install 的,输入
appium plugin install xx
安装一下
4. 插件安装好后输入 appium 报错没有激活:
把这个命令行窗口关了,打开一个新的 cmd 输入:
appium --use-plugins=images,execute-driver,relaxed-caps,universal-xml
四、参考网址
- AppCrawler 自动遍历测试工具实践(一):https://zhuanlan.zhihu.com/p/104899682?open_in_browser=true
- Java+Appium安装和入门测试:https://blog.csdn.net/newpKIN/article/details/131047145?ops_request_misc=&request_id=&biz_id=102&utm_term=Appium+java&utm_medium=distribute.pc_search_result.none-task-blog-2allsobaiduweb~default-2-131047145.142
- Windows平台配置Appium+Java环境:https://blog.csdn.net/weixin_30300523/article/details/98195455?open_in_browser=true
- bilibili教学视频——软件测试/测试开发-自动遍历工具AppCrawler(1):https://www.bilibili.com/video/BV1Ng4y1G73v/?vd_source=869a9c71e2c768e556c19ab08b3bae67; 自动遍历工具AppCrawler(2):https://www.bilibili.com/video/BV1m24y177Xk/?spm_id_from=333.337.search-card.all.click&vd_source=869a9c71e2c768e556c19ab08b3bae67
版权归原作者 If you bloom,butterflies ll come 所有, 如有侵权,请联系我们删除。