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 ...
随机推荐
- JS面向对象设计-理解对象
不同于其他面向对象语言(OO,Object-Oriented),JS的ECMAScript没有类的概念, 它把对象定义为"无序属性(基本值.对象.函数)的集合",类似于散列表. 每 ...
- 组件切换方式(Vue.js)
这里,我用一个注册登录两组件的切换实例来演示: 切换方式一 <!DOCTYPE html> <html lang="zh-CN"> <head> ...
- I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
遇到了这个问题,意思是你的 CPU 支持AVX AVX2 (可以加速CPU计算),但你安装的 TensorFlow 版本不支持 解决:1. 如果是初学者 或者 没有太大计算速度的需求,在开头加上这两行 ...
- PostgreSQL 基本数据类型及常用SQL 函数操作
数据类型 名字 别名 描述 bigint int8 有符号的8字节整数 bigserial serial8 自动增长的8字节整数 bit [ (n) ] 定长位串 bit varying [ (n ...
- Linux 环境变量配置(Nodejs/MongoDB/JDK/Nginx)
一.环境变量配置 注:配置环境变量的文件 全局变量(系统级别): /etc/bashrc /etc/profile /etc/environment 用户变量(用户级别): ~/.bash_profi ...
- Idea中SpringBoot引入thymeleaf没有提示
问题描述: 最近使用Idea搭建SpringBoot时,用到了 thymeleaf,但是出现了点问题:输入th: 代码有没有提示. 解决方法: <html lang="en" ...
- Shell 编程 case语句
本篇主要写一些shell脚本case语句的使用. 字符判断 #!/bin/bash read -p "请输入一个字符:" char case $char in [a-z]|[A-Z ...
- nohup 、&、 2>&1 命令分析
nohup的意思是不间断的运行,&的意思是后台运行,2>&1的意思是标准输出和错误输出都重定向到同一个文件. 简单地说nohup运行时即使关掉控制台,它该运行还是运行. http ...
- Git for Windows安装教程
1.国内直接从官网(http://git-scm.com/download/win)下载比较困难,速度极慢,需要翻墙. 这里提供一个国内的下载站,方便网友下载(https://npm.taobao.o ...
- Visual Studio 调试 ---- 系列文章
调试是软件开发过程中非常重要的一个部分,它具挑战性,但是也有一定的方法和技巧. Visual Studio 调试程序有助于你观察程序的运行时行为并发现问题. 该调试器可用于所有 Visual Stud ...