当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篇)的更多相关文章

  1. 移动端自动化测试(一)之 Appium+Pyhton环境准备篇

    移动端自动化测试(一)之 Appium+Pyhton环境准备篇 2016-11-17 16:51 by CockRoacher, 5046 阅读, 1 评论, 收藏, 编辑 由于工作的需要进行Andr ...

  2. C++混合编程之idlcpp教程Python篇(9)

    上一篇在这 C++混合编程之idlcpp教程Python篇(8) 第一篇在这 C++混合编程之idlcpp教程(一) 与前面的工程相比,工程PythonTutorial7中除了四个文件PythonTu ...

  3. C++混合编程之idlcpp教程Python篇(8)

    上一篇在这 C++混合编程之idlcpp教程Python篇(7) 第一篇在这 C++混合编程之idlcpp教程(一) 与前面的工程相似,工程PythonTutorial6中,同样加入了四个文件:Pyt ...

  4. C++混合编程之idlcpp教程Python篇(7)

    上一篇在这 C++混合编程之idlcpp教程Python篇(6) 第一篇在这 C++混合编程之idlcpp教程(一) 与PythonTutorial4工程相似,工程PythonTutorial5中,同 ...

  5. C++混合编程之idlcpp教程Python篇(6)

    上一篇在这 C++混合编程之idlcpp教程Python篇(5) 第一篇在这 C++混合编程之idlcpp教程(一) 工程PythonTutorial4中加入了四个文件:PythonTutorial4 ...

  6. C++混合编程之idlcpp教程Python篇(5)

    上一篇在这  C++混合编程之idlcpp教程Python篇(4) 第一篇在这 C++混合编程之idlcpp教程(一) 与前面的工程相似,工程PythonTutorial3中,同样加入了三个文件:Py ...

  7. C++混合编程之idlcpp教程Python篇(4)

    上一篇在这 C++混合编程之idlcpp教程Python篇(3) 第一篇在这 C++混合编程之idlcpp教程(一) 与前面的工程相似,工程PythonTutorial2中,同样加入了三个文件 Pyt ...

  8. C++混合编程之idlcpp教程Python篇(3)

    上一篇 C++混合编程之idlcpp教程Python篇(2) 是一个 hello world 的例子,仅仅涉及了静态函数的调用.这一篇会有新的内容. 与PythonTutorial0相似,工程Pyth ...

  9. Noah的学习笔记之Python篇:命令行解析

    Noah的学习笔记之Python篇: 1.装饰器 2.函数“可变长参数” 3.命令行解析 注:本文全原创,作者:Noah Zhang  (http://www.cnblogs.com/noahzn/) ...

随机推荐

  1. getparameter()和getattribution()的区别的 java详细

    两个Web组件之间为转发关系时,转发源会将要共享 request范围内的数据先用setAttribute将数据放入到HttpServletRequest对象中,然后转发目标通过 getAttribut ...

  2. python 数据清洗

    前言 1. 删除重复 2. 异常值监测 3. 替换 4. 数据映射 5. 数值变量类型化 6. 创建哑变量 统计师的Python日记[第7天:数据清洗(1)] 前言 根据我的Python学习计划: N ...

  3. 4.4.6 数组也能无锁:AtomicIntegerArray

    数组也可以实现cas操作,有以下几个类以及用法如下: public class AtomicTntegerArrayTest { public static void main(String[] ar ...

  4. 【转载】mysql中timestamp,datetime,int类型的区别与优劣

    转载来自souldak,微博:@evagle以下内容整合筛选自互联网: int1. 占用4个字节2. 建立索引之后,查询速度快3. 条件范围搜索可以使用使用between4. 不能使用mysql提供的 ...

  5. Hadoop压缩之CompressionCodecFactory

    1.CompressionCodecFactory简介 当在读取一个压缩文件的时候,可能并不知道压缩文件用的是哪种压缩算法,那么无法完成解压任务.在Hadoop中,CompressionCodecFa ...

  6. shiro注解@RequiresPermissions多权限任选一参数用法

    @RequiresPermissions(value={"xxx:xxx","xxx:xxx"},logical=Logical.OR)

  7. ASP.NET MVC ActionFilterAttribute用法

  8. 南昌网络赛J. Distance on the tree 树链剖分+主席树

    Distance on the tree 题目链接 https://nanti.jisuanke.com/t/38229 Describe DSM(Data Structure Master) onc ...

  9. 透明数据加密 (TDE)常见问题解答

    透明数据加密 (TDE)常见问题解答问题任何人只要有权访问加密数据就能对其进行解密吗?TDE 会带来哪些开销?哪些加密算法可与 TDE 一同使用?可以使用第三方加密算法代替 TDE 提供的算法吗?可以 ...

  10. 2018版OCP考试052最新题库及答案-35题

    35.Your database is using Automatic Memory Management. Which two SGA components must be managed manu ...