appium+python+Windows自动化测试文档
appium+python自动化测试文档
一.认识appium
1. 什么是appium
- appium是开源的移动端自动化测试框架;
- appium可以测试原生的、混合的、以及移动端的web项目;
- appium可以测试ios,android应用(当然了,还有firefox os);
- appium是跨平台的,可以用在osx,windows以及linux桌面系统上
2. appium的哲学
- 不需要为了自动化而且重新编译或修改测试app;
- 不应该让移动端自动化测试限定在某种语言和某个具体的框架;也就是说任何人都可以使用自己最熟悉最顺手的语言以及框架来做移动端自动化测试;
- 不要为了移动端的自动化测试而重新发明轮子,重新写一套惊天动地的api;也就是说webdriver协议里的api已经够好了,拿来改进一下就可以了;
- 移动端自动化测试应该是开源的;
二.初步认识appium工作过程
- appium有C/S模式
- appium是基于webdriver协议对移动设备自动化api扩展而成的,所有具有和webdriver一样的特性,比如多语言支持。
- webdriver是基于http协议的,第一连接会建立一个session会话,并通过post发送一个json告知服务端相关测试信息。
- 对于Android来说,4.2以后是基于UiAutomator框架实现查找注入事件的,4.2以前则是instrumentation框架的,并封装成一个叫Selendroid提供服务。
- 客户端只需要发送http请求实现通讯,意味着客户端就是多语言支持的。
- appium服务端是node.js写的,所以安装那个平台都是先安装node,然后npm install -g appium(需要FQ)。
三.环境搭建
需要安装的软件
- JDK:1.8.0_221 环境变量如上图
- Python:3.7.4 环境变量如上图,安装完成会自动完成。
Cmd运行 python
3.node.js:10.16.3
1.安装时会自动添加
2.安装完成后在安装路径下新建两个文件夹node_global、node_cache
3/CMD npm –v 有版本号显示
4.android-sdk 当前最新 最好用SDK Manager.exe下载
Android SDK Tools, Android SDK Platform-Tools,Android SDK Bulid-tools
三个需要文件夹配置Path环境辨率如上图
cmd 运行 adb version 会显示版本号
cmd 运行 android 会执行 Android SDK Manager
5.Appium:1.13.0
官网进行下载安装appium-installer.exe
6.Appium-docto
安装 npm install -g appium-doctor
node_modules\.bin添加到系统环境变量Path中
运行appium-doctor 出现如下图表示环境成功
7.Appium-Python-Client安装步骤
pip install Appium-Python-Client
8.连接手机设备
确定打开开发者模式USB调试
adb device –l 查看连接状态并且能够查看 device:xxx
四.简单使用Appium客户端
前期准备
"platformName": "Android", 测试安卓
"platformVersion": "7", 安卓版本
"deviceName": "leo", adb devices –l 可获取devices名称
aapt dump badging + xxx.apk 可以获取 appPackage,appActivity 2个数据
查看如下字样获取
package: name='cn.gloud.client.mobile'
launchable-activity: name='cn.gloud.client.mobile.init.InitActivity'
"appPackage": "cn.gloud.client.mobile",
"appActivity": "cn.gloud.client.mobile.init.InitActivity"
如下为启动格来云游戏实例:
from appium import webdriver caps = {}
caps["platformName"] = "Android"
caps["platformVersion"] = ""
caps["deviceName"] = "leo"
caps["appPackage"] = "cn.gloud.client.mobile"
caps["appActivity"] = "cn.gloud.client.mobile.init.InitActivity" driver = webdriver.Remote("http://localhost:4723/wd/hub", caps) el1 = driver.find_element_by_xpath("/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.HorizontalScrollView/android.widget.FrameLayout/android.widget.LinearLayout[2]/android.view.View")
el1.click()
el2 = driver.find_element_by_xpath("/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.RelativeLayout/android.support.v4.view.ViewPager/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout[1]/android.widget.RelativeLayout/android.widget.RelativeLayout[1]/android.widget.EditText")
el2.click()
el2.send_keys("账号")
el3 = driver.find_element_by_xpath("/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.RelativeLayout/android.support.v4.view.ViewPager/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.RelativeLayout/android.widget.RelativeLayout[1]/android.widget.EditText")
el3.send_keys("密码")
el4 = driver.find_element_by_id("cn.gloud.client.mobile:id/login_btn")
el4.click()
el5 = driver.find_element_by_id("cn.gloud.client.mobile:id/ad_close_img")
el5.click()
el6 = driver.find_element_by_id("cn.gloud.client.mobile:id/ad_close_img")
el6.click() driver.quit()
appium+python+Windows自动化测试文档的更多相关文章
- appium python andiroid自动化文档整理笔记。
利用一天时间去整理appium for android文档.传送门 利用业余时间自己翻阅资料,google.百度等去查找,费劲一番功夫,最后终于成行了这篇文档. 也是作者对最近自己的学习的一个总结吧, ...
- appium python andiroid自动化文档整理笔记
from appium import webdriver import time,unittest,HTMLTestRunner class Testlogin(unittest.TestCase): ...
- 【转】Python之xml文档及配置文件处理(ElementTree模块、ConfigParser模块)
[转]Python之xml文档及配置文件处理(ElementTree模块.ConfigParser模块) 本节内容 前言 XML处理模块 ConfigParser/configparser模块 总结 ...
- python实用小技能分享,教你如何使用 Python 将 pdf 文档进行 加密 解密
上次说了怎么将word转换为pdf格式 及 实现批量将word转换为pdf格式(点击这里),这次我又get到一个新技能–使用 Python 将 pdf 文档进行 加密 解密,哈哈哈 希望帮到更多人! ...
- 使用Python从Markdown文档中自动生成标题导航
概述 知识与思路 代码实现 概述 Markdown 很适合于技术写作,因为技术写作并不需要花哨的排版和内容, 只要内容生动而严谨,文笔朴实而优美. 为了编写对读者更友好的文章,有必要生成文章的标题导航 ...
- Openstack python api 学习文档 api创建虚拟机
Openstack python api 学习文档 转载请注明http://www.cnblogs.com/juandx/p/4953191.html 因为需要学习使用api接口调用openstack ...
- Python处理Excel文档(xlrd, xlwt, xlutils)
简介 xlrd,xlwt和xlutils是用Python处理Excel文档(*.xls)的高效率工具.其中,xlrd只能读取xls,xlwt只能新建xls(不可以修改),xlutils能将xlrd.B ...
- python+selenium自动化软件测试(第12章):Python读写XML文档
XML 即可扩展标记语言,它可以用来标记数据.定义数据类型,是一种允许用户对自己的标记语言进 行定义的源语言.xml 有如下特征: 首先,它是有标签对组成:<aa></aa> ...
- python 分词计算文档TF-IDF值并排序
文章来自于我的个人博客:python 分词计算文档TF-IDF值并排序 该程序实现的功能是:首先读取一些文档,然后通过jieba来分词,将分词存入文件,然后通过sklearn计算每一个分词文档中的tf ...
随机推荐
- grep匹配命令
关于匹配的实例: 统计所有包含“48”字符的行有多少行 grep -c "48" demo.txt 不区分大小写查找“May”所有的行) grep -i "May&q ...
- Idea中Module is not specified解决办法
打开idea,想跑一个类,但是,给我报了一个红叉: 当我点击run的时候,弹出来一个框: “Error:Module not specified” Module 未指定 “这个原因是项目文件夹有修改 ...
- A Hands-on Look at Using Ray Tracing in Games with UE 4.22 GDC 2019
A Hands-on Look at Using Ray Tracing in Games with UE 4.22 GDC 2019 talker: Sjoerd De Jong (SR.ENGIN ...
- [Cypress] Find Unstubbed Cypress Requests with Force 404
Requests that aren't stubbed will hit our real backend. To ensure we've stubbed all our routes, we c ...
- 【转】别人写的pe代码
// PEOperate.cpp: implementation of the PEOperate class. // //////////////////////////////////////// ...
- python 语音输入
# 系统客户端包 import win32com.client speaker = win32com.client.Dispatch("SAPI.SPVOICE") # 系统接口 ...
- 虚拟机扩展Linux根目录磁盘空间
简要扩展空间方法http://www.kwx.gd/CentOSApp/Xen-Centos6-Mounted-HardDrive.html 最近在VMware虚拟机上使用Centos,用着用着,发现 ...
- 03 HTTP协议与HTTPS协议
一.HTTP协议 1.官方概念: HTTP协议是Hyper Text Transfer Protocol(超文本传输协议)的缩写,是用于从万维网(WWW:World Wide Web )服务器传输超文 ...
- Oracle数据库本地和远程导入、导出
exp本地导出与imp本地导入 exp命令: 1 exp username/psw@TEST file=d:test.dmp full=y 2 exp username/psw@TEST file=d ...
- centos6安装sshpass
跳转机需要装这个 #!/bin/bash yum -y install gcc-c++ openssh-clients curl -o sshpass.tar.gz http://sourceforg ...