Appium入门脚本
没有用框架的代码实现登录功能:
import time
from selenium import webdriver
# 创建字典
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '5.1'
desired_caps['deviceName'] = 'm2 note'
desired_caps['appPackage'] = 'com.test.abc'
desired_caps['appActivity'] = 'com.app.ui.activity.WelcomeActivity'
# 方便输入中文
desired_caps['unicodeKeyboard'] = 'True'
desired_caps['resetKeyboard'] = 'True'
# 每次测试清空缓存
desired_caps['noReset'] = 'False'
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
time.sleep(6)
# 通过xpath定位“去登录”按钮并点击
driver.find_element_by_xpath('/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.TextView[2]').click()
# 输入用户名、密码,点击登录按钮
driver.find_element_by_xpath('/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.EditText').send_keys('username')
driver.find_element_by_xpath('/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.LinearLayout[1]/android.widget.LinearLayout[2]/android.widget.EditText').send_keys('password')
driver.find_element_by_xpath('/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.LinearLayout[2]/android.widget.Button').click()
# 判断是否成功
try:
if driver.find_element_by_xpath("test/test").is_displayed():
print('pass')
except Exception as e:
print(e)
print("fail")
time.sleep(3)
# 资源释放
driver.quit()
Appium入门脚本的更多相关文章
- Appium入门(4)__ Appium Client安装
打算使用 Python 语言编写 appium 自动化测试脚本 一.前提: 1.安装Python语言 到Python官网下载最新版本:https://www.python.org/ 2.安装Pytho ...
- appium入门(1)__ appium介绍
摘自:http://www.testclass.net/appium/appium-base-summary/ 1.特点 appium 是一个自动化测试开源工具,支持 iOS 平台和 Android ...
- Appium入门指南 - 环境搭建和Case编写
本文档将详细介绍如何搭建 Appium 的运行环境,以及如何编写一个简单的 UI 自动化测试用例.其中,也会穿插讲解一些 Appium 的基本知识.关于 Appium 的更多信息,大家可以查看官方文档 ...
- appium入门
前语:学习需要总结,或许有些知识自己存在偏差,但是能总结出来就会更加加深所学知识 1. 环境变量配置 必备软件安装: jdk1.6.0 android-sdk python:2.7(3.6 ...
- Appium入门(6)__appium-desktop安装
部分摘自:http://www.testclass.net/appium/appium-base-desktop/ Appium-Server主要用来监听移动设备,然后将不同编程语言编写的 appiu ...
- Appium录制脚本520-2
1.录制自动化脚本 场景:启动雪球,点击我的,登陆雪球,选择手机及其他登陆,输入手机号 2.使用Java进行测试Appium测试 2.1创建Java工程 file-创建maven工程-填写GroupI ...
- appium入门知识
UI自动化相关工具 1.appium平台 2.Apple的UIAutomation 3.Google的UIAutomation 简单的介绍一下这几个工具: 1.Appium简介 Appium使用Web ...
- appium入门篇之desired capabilities(2)
目录 1.appium工作原理 desired capabilities 2.准备工作 3.第一个appium脚本 获取包名和启动的activity 编写脚本 运行结果 1.appium工作原理 启动 ...
- Appium入门示例(python)
安装Python依赖 pip3.4 install nose pip3.4 install selenium pip3.4 install Appium-Python-Client 运行测试用例and ...
随机推荐
- AppiumLibrary 关键字文档
http://serhatbolsu.github.io/robotframework-appiumlibrary/AppiumLibrary.html#Start%20Activity
- 阿里熔断限流Sentinel研究
1. 阿里熔断限流Sentinel研究 1.1. 功能特点 丰富的应用场景:例如秒杀(即突发流量控制在系统容量可以承受的范围).消息削峰填谷.集群流量控制.实时熔断下游不可用应用等 完备的实时监控:S ...
- Electron学习入门
1.安装electron,不建议全局安装,这样每个app可以使用不同的electron版本了 2.配置package.json中的script下的start属性的值为electron . Electr ...
- 91.用js遍历原生json数据
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8 ...
- memcpy函数的实现
1.按1个字节拷贝 (1)不要直接使用形参,要转换成char* (2)目标地址要实现保存 (3)要考虑源和目标内存重叠的情况 void * mymemcpy(void *dest, const voi ...
- Pycharm安装模块提示module 'pip' has no attribute 'main'的问题
解决pycharm问题:module 'pip' has no attribute 'main' 转自: <解决pycharm问题:module 'pip' has no attribute ' ...
- Prometheus学习笔记(5)Grafana可视化展示
目录 一.Grafana安装和启动 二.配置数据源 三.配置dashboard 四.配置grafana告警 一.Grafana安装和启动 Grafana支持查询Prometheus.从Grafana ...
- Httpd服务进阶知识-基于FASTCGI实现的LAMP架构
Httpd服务进阶知识-基于FASTCGI实现的LAMP架构 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.httpd+php结合的方式 module: php fastcgi ...
- Docker 版ansible galera集群
1. 部署galera集群 利用四台主机cicd.node1.node2.node3来搭建galera集群. 1> 上传压缩包至cicd,解压得到ansible配置文件 [root@cicd ~ ...
- ELK快速入门(四)filebeat替代logstash收集日志
ELK快速入门四-filebeat替代logstash收集日志 filebeat简介 Filebeat是轻量级单用途的日志收集工具,用于在没有安装java的服务器上专门收集日志,可以将日志转发到log ...