当Appium中遇到alert(python篇)
当Appium中遇到alert,可以使用switch_to_alert(),以下是微信登录切换登录方式的代码示例:
#coding=utf-8
from appium import webdriver
from time import sleep
import unittest class WxTestsCase(unittest.TestCase):
def setUp(self):
desired_cups={}
desired_cups['platformName']='Android'
desired_cups['platformVersion']='4.4.2'
desired_cups['deviceName']='DU2SSE15A9032675'
desired_cups['appPackage']='com.tencent.mm'
desired_cups['appActivity']='com.tencent.mm.ui.LauncherUI'
self.dr=webdriver.Remote("http://localhost:4725/wd/hub",desired_cups)
sleep(10)
def login(self):
self.dr.find_element_by_id('com.tencent.mm:id/ba_').click()
self.dr.switch_to_alert() #切换到alert窗口
self.dr.find_element_by_id('com.tencent.mm:id/et').click() #点击弹窗上的切换账号选项 if __name__ == '__main__':
suite = unittest.TestSuite()
suite.addTest(WxTestsCase('login'))
# suite.addTest(cleanTestsCase('youhua'))
# suite.addTest(cleanTestsCase('usual'))
unittest.TextTestRunner(verbosity=2).run(suite)
#coding=utf-8
from appium import webdriver
from time import sleep
import unittest class WxTestsCase(unittest.TestCase):
def setUp(self):
desired_cups={}
desired_cups['platformName']='Android'
desired_cups['platformVersion']='4.4.2'
desired_cups['deviceName']='DU2SSE15A9032675'
desired_cups['appPackage']='com.tencent.mm'
desired_cups['appActivity']='com.tencent.mm.ui.LauncherUI'
self.dr=webdriver.Remote("http://localhost:4725/wd/hub",desired_cups)
sleep(10)
def login(self):
self.dr.find_element_by_id('com.tencent.mm:id/ba_').click()
self.dr.switch_to_alert() #切换到alert窗口
self.dr.find_element_by_id('com.tencent.mm:id/et').click() #点击弹窗上的切换账号选项 if __name__ == '__main__':
suite = unittest.TestSuite()
suite.addTest(WxTestsCase('login'))
# suite.addTest(cleanTestsCase('youhua'))
# suite.addTest(cleanTestsCase('usual'))
unittest.TextTestRunner(verbosity=2).run(suite)
当Appium中遇到alert(python篇)的更多相关文章
- 移动端自动化测试(一)之 Appium+Pyhton环境准备篇
移动端自动化测试(一)之 Appium+Pyhton环境准备篇 2016-11-17 16:51 by CockRoacher, 5046 阅读, 1 评论, 收藏, 编辑 由于工作的需要进行Andr ...
- C++混合编程之idlcpp教程Python篇(9)
上一篇在这 C++混合编程之idlcpp教程Python篇(8) 第一篇在这 C++混合编程之idlcpp教程(一) 与前面的工程相比,工程PythonTutorial7中除了四个文件PythonTu ...
- C++混合编程之idlcpp教程Python篇(8)
上一篇在这 C++混合编程之idlcpp教程Python篇(7) 第一篇在这 C++混合编程之idlcpp教程(一) 与前面的工程相似,工程PythonTutorial6中,同样加入了四个文件:Pyt ...
- C++混合编程之idlcpp教程Python篇(7)
上一篇在这 C++混合编程之idlcpp教程Python篇(6) 第一篇在这 C++混合编程之idlcpp教程(一) 与PythonTutorial4工程相似,工程PythonTutorial5中,同 ...
- C++混合编程之idlcpp教程Python篇(6)
上一篇在这 C++混合编程之idlcpp教程Python篇(5) 第一篇在这 C++混合编程之idlcpp教程(一) 工程PythonTutorial4中加入了四个文件:PythonTutorial4 ...
- C++混合编程之idlcpp教程Python篇(5)
上一篇在这 C++混合编程之idlcpp教程Python篇(4) 第一篇在这 C++混合编程之idlcpp教程(一) 与前面的工程相似,工程PythonTutorial3中,同样加入了三个文件:Py ...
- C++混合编程之idlcpp教程Python篇(4)
上一篇在这 C++混合编程之idlcpp教程Python篇(3) 第一篇在这 C++混合编程之idlcpp教程(一) 与前面的工程相似,工程PythonTutorial2中,同样加入了三个文件 Pyt ...
- C++混合编程之idlcpp教程Python篇(3)
上一篇 C++混合编程之idlcpp教程Python篇(2) 是一个 hello world 的例子,仅仅涉及了静态函数的调用.这一篇会有新的内容. 与PythonTutorial0相似,工程Pyth ...
- Noah的学习笔记之Python篇:命令行解析
Noah的学习笔记之Python篇: 1.装饰器 2.函数“可变长参数” 3.命令行解析 注:本文全原创,作者:Noah Zhang (http://www.cnblogs.com/noahzn/) ...
随机推荐
- Java Persistence with MyBatis 3(中文版) 前言
对很多软件系统而言,保存数据到数据库和从数据库中检索数据是其工作流程中至关重要的一部分.在 Java 领域,有很多的实现了数据持久化层的工具和框架,它们每一个都有自己不同的实现方法.而 MyBatis ...
- ceph中pool的管理
1.创建pool 创建ceph pool的命令如下,它的参数包括pool名字.PG和PGP的数量. 若少于5个OSD, 设置pg_num为128. 5~10个OSD,设置pg_num为512. 10~ ...
- windows 安装 mysql5.7.17
下载mysql 进入官网:https://www.mysql.com/ 单击[Downloads]选项卡 最下面有个[ MySQL Community Edition (GPL)],单击[Commu ...
- [LeetCode 题解]: Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...
- 操作Word的辅助类(word2003)
该类在他人编写的几个类基础上扩展完善而来,主要功能有: (1)插入文本 (2)插入图片 (3)插入表格 (4)载入模版 (5)编辑模版,利用标签等 (6)插入页眉页脚 /*************** ...
- How to design a product table for many kinds of product where each product has many parameters
https://stackoverflow.com/questions/695752/how-to-design-a-product-table-for-many-kinds-of-product-w ...
- 实战iOS7之NSURLSession
NSURLSession VS NSURLConnection NSURLSession可以看做是NSURLConnection的进化版,其对NSURLConnection的改进点有: * 根据每个S ...
- sql添加列,删除列,修改列
有时候,当数据库里面有数据了,再到设计器里面删除列,就删不掉.只能用代码删除. alter table tableName drop column columnName 添加列 ) 修改列 ) --修 ...
- python下使用tesserocr遇到的一些坑
我是在win7 64位系统下用的. 首先是安装tesseract,这个可以去官网下载,我使用的是3.05.1,安装时使用默认安装路径就行了,下载语言包速度很慢很慢,需要等 接下来就是安装tessero ...
- Windows上编译LLVM 3.2
LLVM还是做的很好的,可以很方便的编译. 解压LLVM 3.2到[工作目录]/llvm/llvm-3.2.src 解压Clang到[工作目录]/llvm/llvm-3.2.src/tools/cla ...