App UI自动化测试之Mac环境安装appium

依赖环境:

  • java
✗ java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
  • python
$python --version
Python 3.6.4
  • node.js
$node -v
v10.6.0
如果未安装,通过以下命令安装:
$brew install node
  • android sdk、环境配置(网上很多,这里不复述)
$adb
Android Debug Bridge version 1.0.39
Revision 3db08f2c6889-android
Installed as /Users/xxx/Android/sdk/platform-tools/adb

global options:
 -a         listen on all network interfaces, not just localhost
 -d         use USB device (error if multiple devices connected)
 -e         use TCP/IP device (error if multiple TCP/IP devices available)
 -s SERIAL
...
  • Appium

安装Appium有两种方式,
1. 直接去官网下载dmg安装包
2. 命令行安装(也是官方提供)(安装过程有点慢,耐心等待)

> brew install node      # get node.js
> npm install -g appium  # get appium
> npm install wd         # get appium client
> appium &               # start appium

其中,安装appium时,即执行npm install -g appium,会出现一些警告warning,忽略即可。类似如下

/Users/xxx/.node-gyp/10.6.0/include/node/v8.h:7354:3: note: 'GetCpuProfiler' has been explicitly marked deprecated here
  V8_DEPRECATED("CpuProfiler should be created with CpuProfiler::New call.",
  ^
/Users/xxx/.node-gyp/10.6.0/include/node/v8config.h:327:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
../src/heapdump.cc:106:23: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
    String::Utf8Value filename_string(args[0]);
                      ^
/Users/xxx/.node-gyp/10.6.0/include/node/v8.h:2851:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^

安装完毕,测试是否安装成功。

$appium -v
1.8.1

启动appium服务

appium或者appium &

$appium  
(node:39581) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[Appium] Welcome to Appium v1.8.1
[Appium] Appium REST http interface listener started on 0.0.0.0:4723

关闭appium服务。

  • 如果使用appium启动服务,则直接cmd+c即可强制关闭服务:
$appium
(node:40425) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[Appium] Welcome to Appium v1.8.1
[Appium] Appium REST http interface listener started on 0.0.0.0:4723

^C[Appium] Received SIGINT - shutting down
  • 如果使用appium &启动服务,cmd+c是无效的,可以看到和上边方式的区别,不会收到shut down指令,即Received SIGINT - shutting down。此时服务仍在运行,如果重新启动,则报错,如下:
$appium &         
[1] 40481
$ (node:40481) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[Appium] Welcome to Appium v1.8.1
[Appium] Appium REST http interface listener started on 0.0.0.0:4723

$appium
(node:40574) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[Appium] Welcome to Appium v1.8.1
[HTTP] Could not start REST http interface listener. The requested port may already be in use. Please make sure there is no other instance of this server running already.
Fatal Error: listen EADDRINUSE 0.0.0.0:4723
    at Server.setupListenHandle [as _listen2] (net.js:1335:14)
    at listenInCluster (net.js:1383:12)
    at doListen (net.js:1509:7)
    at process._tickCallback (internal/process/next_tick.js:63:19)

此时,需要强制kill服务,使用ps获取appium服务进程,然后kill

$ps | grep appium
40481 ttys002    0:02.00 node /usr/local/bin/appium
40668 ttys002    0:00.00 grep --color appium
$kill -9 40481
[1]  + 40481 killed     appium

更多博客,请关注
https://blog.csdn.net/rflyee/
https://www.jianshu.com/u/ff8bcd76e5a7

你可能感兴趣的:(Python,appnium,mac,python,自动化测试,Android)