python+Appium环境搭建

 

 

第一、安装和配置android SDK

关于安装和配置android SDK的方式,可以查看下面的链接

http://www.cnblogs.com/JcHome/p/8268477.html

 

第二、安装Node.js

Node.js的下载路径:http://nodejs.cn/download/

 检查node.js是否正常:node -v

 

 

第三、安装Appium

Appium的下载路径:https://bitbucket.org/appium/appium.app/downloads/

安装过程比较简单,基本上都是下一步

安装完成后,配置环境变量,在path路径中添加:安装路径下的node_modules\.bin路径;如:D:\tools\appium\Appium\node_modules\.bin;

在dos中输入:appium-doctor,显示如下信息说明安装正常

 

 

第四、安装Python

python下载路径:https://www.python.org/

python安装步骤在此,忽略下面是python的环境变量配置:

(添加一个python_home变量,值为:python的安装路径)

 

(将python_home添加到path环境变量中)

(出现上图信息,表示python环境变量已经配置成功)

 安装setuptools工具,下载路径:https://pypi.python.org/pypi/setuptools/

下载后解压,cd 进入到解压目录中

执行python setup.py  install 进行setuptools工具的安装

安装pip工具,下载路径:https://pypi.python.org/pypi/pip

下载完成后,也是解压,然后进入到解压的目录,含有如下目录

执行python setup.py install 命令,进行安装

pip工具安装完成后,在python路径下的Scripts目录中,会显示有pip.exe的可执行文件,通过这个工具可以从网下下载其他的python第三方共享的插件

 

第五、安装Appium-Python-Client

进入python/Scripts目录,通过pip命令安装Appium-Python-Client

安装完成后,可以通过pip show Appium-Python-Client 指令查看版本信息

 

 

测试脚本

 

 

常见问题:

1.chromedriver.exe 与android 的chrome 内核版本号不匹配,导致启动链接appium 失败

 info: Chromedriver: Changed state to 'stopped'
> warn: Chromedriver for context WEBVIEW_com.tencent.mm:tools stopped unexpectedly
> error: Chromedriver: Chromedriver exited unexpectedly with code null, signal SIGTERM
> warn: Chromedriver quit unexpectedly, but it wasn't the active context, ignoring
> error: Chromedriver: Error: A new session could not be created. (Original error: session not created exception
> from unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"11998.1","isDefault":true},"id":1,"name":"","origin":"://"}
>   (Session info: chrome=57.0.2987.132)
>   (Driver info: chromedriver=2.19.346078 (6f1f0cde889532d48ce8242342d0b84f94b114a1),platform=Windows NT 10.0 x86_64))
>     at JWProxy.command$ (lib/proxy.js:133:15)
>     at tryCatch (E:\tools\App_tools\Appium\Appium\node_modules\appium\node_modules\appium-chromedriver\node_modules\appium-jsonwp-proxy\node_modules\babel-runtime\regenerator\runtime.js:67:40)
>     at GeneratorFunctionPrototype.invoke [as _invoke] (E:\tools\App_tools\Appium\Appium\node_modules\appium\node_modules\appium-chromedriver\node_modules\appium-jsonwp-proxy\node_modules\babel-runtime\regenerator\runtime.js:315:22)
>     at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (E:\tools\App_tools\Appium\Appium\node_modules\appium\node_modules\appium-chromedriver\node_modules\appium-jsonwp-proxy\node_modules\babel-runtime\regenerator\runtime.js:100:21)
>     at GeneratorFunctionPrototype.invoke (E:\tools\App_tools\Appium\Appium\node_modules\appium\node_modules\appium-chromedriver\node_modules\appium-jsonwp-proxy\node_modules\babel-runtime\regenerator\runtime.js:136:37)
>     at bound (domain.js:284:14)
>     at GeneratorFunctionPrototype.runBound (domain.js:297:12)
>     at run (E:\tools\App_tools\Appium\Appium\node_modules\appium\node_modules\appium-chromedriver\node_modules\appium-jsonwp-proxy\node_modules\babel-runtime\node_modules\core-js\library\modules\es6.promise.js:89:39)
>     at E:\tools\App_tools\Appium\Appium\node_modules\appium\node_modules\appium-chromedriver\node_modules\appium-jsonwp-proxy\node_modules\babel-runtime\node_modules\core-js\library\modules\es6.promise.js:100:28
>     at flush (E:\tools\App_tools\Appium\Appium\node_modules\appium\node_modules\appium-chromedriver\node_modules\appium-jsonwp-proxy\node_modules\babel-runtime\node_modules\core-js\library\modules\$.microtask.js:17:13)
>     at process._tickDomainCallback (node.js:381:11)
>  { [Error: A new session could not be created. (Original error: session not created exception
> from unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"11998.1","isDefault":true},"id":1,"name":"","origin":"://"}
>   (Session info: chrome=57.0.2987.132)
>   (Driver info: chromedriver=2.19.346078 (6f1f0cde889532d48ce8242342d0b84f94b114a1),platform=Windows NT 10.0 x86_64))]
>   status: 33,
>   value: { message: 'session not created exception\nfrom unknown error: Runtime.executionContextCreated has invalid \'context\': {"auxData":{"frameId":"11998.1","isDefault":true},"id":1,"name":"","origin":"://"}\n  (Session info: chrome=57.0.2987.132)\n  (Driver info: chromedriver=2.19.346078 (6f1f0cde889532d48ce8242342d0b84f94b114a1),platform=Windows NT 10.0 x86_64)' },
>   httpCode: 200 }

 解决方式:

  下载对应的chrome的chromedriver.exe版本号,放到Appium\Appium\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win路径下,重启appium,即可

chromedriver 驱动下载地址:http://chromedriver.storage.googleapis.com/index.html

 

 

posted @ 2018-01-17 21:42  西夏一品唐  阅读(322)  评论(0编辑  收藏  举报