Windows&Appium&Java&Python自动化测试-开发环境

一、摘要

本篇博文,主要介绍借助Appium做移动端自动化测试的开发环境搭建,包括Java和Python

Java环境:Appium+Maven+Idea+TestNG+Ngreport

Python环境:Appium+Pycharm+Unittest

二、Java环境

用MAVEN建立项目的好处:

优点一:项目非常大时,可借助Maven将一个项目拆分成多个工程,最好是一个模块对应一个工程,利于分工协作。而且模块之间还是可以发送消息的。

优点二:借助Maven,可将jar包仅仅保存在“仓库”中,有需要该文件时,就引用该文件接口,不需要复制文件过来占用空间。

优点三:借助Maven可以以规范的方式下载jar包,因为所有的知名框架或第三方工具的jar包已经按照统一的规范存放到了Maven的中央仓库中。

优点四:Maven会自动将你要加入到项目中的jar包导入,不仅导入,而且还会将该jar包所依赖的jar包都自动导入进来。

官方地址:http://maven.apache.org/download.cgi

下载安装后配置MVN环境变量,如下图所示

变量名可用M2_HOME或者MAVEN_HOME

变量值就是安装目录,如果JDK配的很遛,这个同理

PATH:%M2_HOME%\bin;

检查Maven环境

配置MVN本地仓库物理地址,也就是maven会从中央仓库下载需要的jar包到本地

再次路径下打开setting.xml,配置项如下,注意XML节点,地址随意

配置MVN中央仓库

保存配置后,将该文件复制如下路径下

此处单配置了一个镜像地址,是阿里云的地址,官方地址下载太慢可以通过这个位置的配置代替

配置IDEA,IDEA官方下载地址:https://www.jetbrains.com/idea/download/,默认安装即可

打开IDEA,新建一个maven项目,检查Maven的配置如图所示,箭头所指两个配置已经更新到了前边步骤中的位置

IDEA会在右下角(注意右下角)提示你是否需要自动安装pom配置的jar包,一旦出现,就要enable它找到pom.xml文件,打开它,配置项目所需的依赖包,如下图配置
 1     <dependencies>
 2         <!--- 导入webdriver相关   -->
 3         <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server -->
 4         <dependency>
 5             <groupId>org.seleniumhq.selenium</groupId>
 6             <artifactId>selenium-server</artifactId>
 7             <version>3.12.0</version>
 8         </dependency>
 9
10         <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
11         <dependency>
12             <groupId>org.seleniumhq.selenium</groupId>
13             <artifactId>selenium-java</artifactId>
14             <version>3.12.0</version>
15         </dependency>
16
17         <!-- https://mvnrepository.com/artifact/org.testng/testng -->
18         <dependency>
19             <groupId>org.testng</groupId>
20             <artifactId>testng</artifactId>
21             <version>6.14.3</version>
22             <scope>test</scope>
23         </dependency>
24         <!-- https://mvnrepository.com/artifact/io.appium/java-client -->
25         <dependency>
26             <groupId>io.appium</groupId>
27             <artifactId>java-client</artifactId>
28             <version>4.0.0</version>
29         </dependency>
30             <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
31         <dependency>
32             <groupId>org.apache.logging.log4j</groupId>
33             <artifactId>log4j-api</artifactId>
34             <version>2.11.1</version>
35         </dependency>
36         <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
37         <dependency>
38             <groupId>org.apache.logging.log4j</groupId>
39             <artifactId>log4j-core</artifactId>
40             <version>2.11.1</version>
41         </dependency>
42         <dependency>
43             <groupId>log4j</groupId>
44             <artifactId>log4j</artifactId>
45             <version>1.2.17</version>
46             <scope>test</scope>
47         </dependency>
48     </dependencies>

配置监听

 1     <build>
 2         <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
 3             <plugins>
 4                 <plugin>
 5                     <groupId>org.apache.maven.plugins</groupId>
 6                     <artifactId>maven-surefire-plugin</artifactId>
 7                     <version>2.20.1</version>
 8                     <configuration>
 9                         <properties>
10                             <property>
11                                 <name>usedefaultlisteners</name>
12                                 <value>false</value>
13                             </property>
14                             <property>
15                                 <!--使用reportng的 listener 生成测试报告-->
16                                 <name>listener</name>
17                                 <value>org.uncommons.reportng.HTMLReporter, org.uncommons.reportng.JUnitXMLReporter</value>
18                             </property>
19                         </properties>
20                         <testFailureIgnore>true</testFailureIgnore>
21                         <!--指定testng.xml的位置-->
22                         <suiteXmlFiles>
23                             <file>testng.xml</file>
24                         </suiteXmlFiles>
25                         <workingDirectory>target/</workingDirectory>
26                         <forkMode>always</forkMode>
27                     </configuration>
28                 </plugin>
29                 <plugin>
30                     <artifactId>maven-clean-plugin</artifactId>
31                     <version>3.0.0</version>
32                 </plugin>
33                 <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
34                 <plugin>
35                     <artifactId>maven-resources-plugin</artifactId>
36                     <version>3.0.2</version>
37                 </plugin>
38                 <plugin>
39                     <artifactId>maven-compiler-plugin</artifactId>
40                     <version>3.7.0</version>
41                 </plugin>
42                 <plugin>
43                     <artifactId>maven-jar-plugin</artifactId>
44                     <version>3.0.2</version>
45                 </plugin>
46                 <plugin>
47                     <artifactId>maven-install-plugin</artifactId>
48                     <version>2.5.2</version>
49                 </plugin>
50                 <plugin>
51                     <artifactId>maven-deploy-plugin</artifactId>
52                     <version>2.8.2</version>
53                 </plugin>
54             </plugins>
55         </pluginManagement>
56     </build>

到此Java环境完成

Pom中配置的依赖可以在MVN的中央库http://mvnrepository.com/, 检索到你想要的包,配置进去即可

三、Python环境

Python的环境相对简单很多,因为已经有了unittest,我们再安装Appium相关模块即可

在CMD中运行 pip install Appium-Python-Client

Pycharm官方下载地址:https://www.jetbrains.com/pycharm/download/

原文地址:https://www.cnblogs.com/davieyang/p/10060946.html

时间: 2024-08-01 16:15:31

Windows&Appium&Java&Python自动化测试-开发环境的相关文章

windows 7搭建python+django开发环境

windows 7 64位,搭建python+django 开发环境实践 一.安装python 因为要应用于京东云或百度云引擎,选择2.7.4.到python官网下载相应版本并安装.安装完成后,需要配置环境变量,Path中添加c:\python27,我直接安装在c盘根目录下. cmd输入python回车,进入python环境,ok结束 二.安装django  到官网下载相应版本包,然后解压,cmd工作目录切换到解压路径,运行python setup.py install 报错:ImportErr

《Python入门》Windows 7下Python Web开发环境搭建笔记

最近想尝试一下在IBM Bluemix上使用Python语言创建Web应用程序,所以需要在本地搭建Python Web的开发测试环境. 关于Python的版本 进入Python的网站,鼠标移到导航条上的下载,我们会发现提供两下主版本的下载链接! 这两个之间存在什么差别呢? 个人理解,2.7.x的版本为更加稳定的版本,而3.x的版本则是比较前卫的版本,包含了很多新功能新特性之类的: 但如果想要用Python开发一个新项目,那么该如何选择Python版本呢?大部分Python库都同时支持Python

windows上搭建python+gvim开发环境

参照了 http://www.cnblogs.com/xd502djj/archive/2010/09/16/1827683.html ,发现有些问题,所以修改了一些. Vim as Python IDE on windows(转) 下载安装Python. 从Vim的网站下载vim,建议下Self-installing executable的版本. 编辑vim的配置文件_vimrc,windows的_vimrc用户文件可以在用户目录下创建. 设置中文支持 " 设置编码自动识别, 中文引号显示 &

windows和linux中搭建python集成开发环境IDE——如何设置多个python环境

本系列分为两篇: 1.[转]windows和linux中搭建python集成开发环境IDE 2.[转]linux和windows下安装python集成开发环境及其python包 3.windows和linux中搭建python集成开发环境IDE——如何设置多个python环境 Install Python packages on Ubuntu 14.04 from chris' sandbox In this post I will document my setup of Python 2.7

《Python入门》Linux 下 Python Web开发环境搭建笔记

之前写过 Windows 7下Python Web开发环境搭建笔记,今天写一下在Linux系统下搭建Python Web的开发测试环境. 我使用的系统是:ubuntu 14.04 server,根据个人经验,CentOS 6.5 下也适用. 关于Python的版本 进入Python的网站,鼠标移到导航条上的下载,我们会发现提供两下主版本的下载链接! 这两个之间存在什么差别呢? 个人理解,2.7.x的版本为更加稳定的版本,而3.x的版本则是比较前卫的版本,包含了很多新功能新特性之类的: 但如果想要

手机自动化测试:搭建appium手机自动化测试开发环境

poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.如果对课程感兴趣,请大家咨询qq:908821478.poptest已经开始了移动测试开发的课程,在课程中加入了公司的实际案例,学员上课的过程中感觉课程难度很高,我们在想办法保证课程的难度和深度的情况,调整教学方式让学员可以在同样的时间里掌握更深的知识. 本次和大家分享appium的环境搭建. 第一步:安装appium,我安装的是<AppiumForWindows-1.0.0.3

【转】windows和linux中搭建python集成开发环境IDE

http://blog.csdn.net/pipisorry/article/details/39854707 使用的系统及软件Ubuntu / windowsPython 2.7 / python 3Pycharm 2.6.3Openjdk Postgresql 9.1VirtualenvVirtualenvwrapper{开始之前,可以给系统做一下备份.如误安装了Postgresql,出现了大问题就不得不把系统给重装了} 安装python 安装python 1. Ubuntu 12.04系统

windows下python web开发环境的搭建

windows下python web开发环境: python2.7,django1.5.1,eclipse4.3.2,pydev3.4.1 一. python环境安装 https://www.python.org/ftp/python/2.7/python-2.7.amd64.msi 不多说,装完后把C:\Python27加入到path环境变量里. 然后就溜溜python,看看version啦.OK,next step. 二. python web开发框架django安装 django是一个采用

在windows下用eclipse + pydev插件来配置python的开发环境

一.安装 python 可以到网上下个Windows版的python,官网为:https://www.python.org/downloads/下好后直接安装就ok了.最后记得配置一下环境变量,具体操作如下: 1)在计算机属性的环境变量配置中找到path, 2 )编辑path值,添加你安装的python路径, 3)检验python是否安装配置成功,打开cmd,输入python,如果出现以下界面,则说 明你的python安装成功了 二.安装eclipse插件 装插件的前提是先安装eclipse,e