Ubuntu系统中安装Macaca过程记录

系统之前已经apt-get install过git,node。
git version 2.17.1
node v8.10.0

安装jdk环境
下载地址:
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
jdk-8u201-linux-x64.tar.gz
解压:

$ tar -zxvf jdk-8u201-linux-x64.tar.gz /usr/local/jdk180_201
配置环境:
$vim /etc/profile 末尾:
#java 1.8
export JAVA_HOME=/usr/local/jdk180_201
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=.:${JAVA_HOME}/bin:$PATH
测试:
$source /etc/profile
$java --version

java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)

安装android环境:
下载地址:
https://www.androiddevtools.cn/
SDK Tools:
androiddk_r24.4.1-linux.tgz

解压:$tar zxvf androiddk_r24.4.1-linux.tgz  /usr/local/android-sdk-linux
配置环境:
$vim /etc/profile 末尾
#android sdk 24 
export  ANDROID_HOME=/usr/local/android-sdk-linux
export  PATH=$PATH::$ANDROID_HOME/tools/:$ANDROID_HOME/platform-tools
$cd /usr/local/android-sdk-linux/tools
$./android update sdk

在 界面 Android SDK Manager选择:
tools:android sdk tools,android sdk platform-tools, android sdk build-tools
android 8.1.0 (api 27):sdk platform
extras: android support repository
然后install packages

安装gradle:
https://gradle.org/install/

$ brew install gradle
配置环境:
$vim /etc/profile
#gradle
export PATH=$PATH:/home/linuxbrew/.linuxbrew/Cellar/gradle/5.2.1/bin
测试:
$grade -v

Gradle 5.2.1

Build time: 2019-02-08 19:00:10 UTC
Revision: f02764e074c32ee8851a4e1877dd1fea8ffb7183

Kotlin DSL: 1.1.3
Kotlin: 1.3.20
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 1.8.0_201 (Oracle Corporation 25.201-b09)
OS: Linux 4.15.0-43-generic amd64

安装macaca-android:

$ MAVEN_MIRROR_URL=http://maven.aliyun.com/nexus/content/groups/public/ npm i macaca-android -g
$cd /usr/local/android-sdk-linux/
$mkdir licenses
$vim android-sdk-license,添加如下内容
8933bad161af4178b1185d1a37fbf41ea5269c55

安装Macaca:
$ npm i -g macaca-cli

安装驱动:macaca-chrome, macaca-electron
$npm i macaca-chrome -g
$npm i macaca-electron -g
查看本机chrome版本:版本 65.0
下载对应chromedriver:(2.36,具体可以查阅http://npm.taobao.org/mirrors/chromedriver/2.36/notes.txt)
http://npm.taobao.org/mirrors/chromedriver/
http://npm.taobao.org/mirrors/chromedriver/2.36/chromedriver_linux64.zip
$unzip chromedriver_linux64.zip
$mv chromedriver /usr/local/lib/node_modules/macaca-chrome/node_modules/macaca-chromedriver/exec
$mv chromedriver chromedriver2.45 (必须和之前文件名一致)

测试:
$macaca -v
2.1.11
$macaca doctor

macaca-doctor version: 2.0.15

Node.js checklist:

node env: /usr/bin/node
node version: v8.10.0

Android checklist:

JAVA version is 1.8
JAVA_HOME is set to /usr/local/jdk180_201
ANDROID_HOME is set to /usr/local/android-sdk-linux
Platforms is set to /usr/local/android-sdk-linux/platforms/android-27
ADB tool is set to /usr/local/android-sdk-linux/platform-tools/adb
TypeError: Cannot read property '0' of undefined
at checkJavaHome.then.catch.then.then.catch.then.std (/usr/local/lib/node_modules/macaca-cli/node_modules/java-home/lib/java-home.js:92:27)
at
gradle is installed, version: 5.2

Installed driver list:

android: 2.0.48
chrome: 1.1.0
electron: 2.1.3

注:TypeError: Cannot read property '0' of undefined
at checkJavaHome.then.catch.then.then.catch.then.std (/usr/local/lib/node_modules/macaca-cli/node_modules/java-home/lib/java-home.js:92:27)
at
该错误暂为解决

测试案例:(sample-python)
参考:https://github.com/macaca-sample/sample-python

$ pip install -r requirements.txt
$cd ~/macaca/
$git clone https://github.com/macaca-sample/sample-python.git
$vim sample-python/tests/macaca-desktop-sample.test
#    'browserName': 'electron'
    'browserName': 'chrome'
(或者:https://testerhome.com/topics/6233
$ npm uninstall macaca-electron -g
$npm i macaca-electron -g
)
$ macaca server --verbose

新开终端:
python tests/macaca-desktop-sample.test.py
出现chrome测试界面

参考文章:
https://macacajs.github.io/zh/guide/
https://testerhome.com/topics/5509

你可能感兴趣的:(Ubuntu系统中安装Macaca过程记录)