当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. 迁移ORACLE数据库文件到ASM

    迁移数据文件到ASM 数据库一致性情况下迁移:将数据库启动到mount状态,生成rman copy 语句,然后在rman中执行: SQL> startup mount SQL> selec ...

  2. ceph的image扩容

    root@ceph01:/etc/ceph# rbd create --size 1024 test root@ceph01:/etc/ceph# root@ceph01:/etc/ceph# roo ...

  3. Caused by: org.hibernate.HibernateException: Unable to build the default ValidatorFactory

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testAction': ...

  4. SSH 密钥登录 SecureCRT

    https://www.qcloud.com/doc/product/213/2036 1.3. 使用SecureCRT登录 1.3.1. 复制公钥 登录腾讯云控制台,点击[云服务器]-[SSH密钥] ...

  5. jquery stop(true,false)的意思

    stop 是jQuery中用于控制页面动画效果的方法.运行之后立刻结束当前页面上的动画效果.stop在新版jQuery中添加了2个参数:第一个参数的意思是是否清空动画序列,也就是stop的是当前元素的 ...

  6. duilib入门简明教程 -- XML配置界面(6)

       前面那些教程都是为了让小伙伴们从win32.MFC过渡到duilib,让大家觉得duilib不是那么陌生,如果大家现在还对duilib非常陌生的话,那就说明前面的教程做得不好,请大家在下面留言, ...

  7. Transaction And Lock--在事务中使用TRY CATCH

    1>当XACT_ABORT被设置为ON时,如果TSQL 语句遇到运行时错误,整个事务会被回滚和结束2>当XACT_ABORT被设置为OFF时,如果TSQL 语句遇到运行时错误,只会回滚当前 ...

  8. 【Newtonsoft.Json.dll】操作列表JSON数据

    JObject data = JObject.Parse(json); JArray array = JArray.Parse(data["list"] + "" ...

  9. c#进阶之浅析委托和事件

    何为委托 加了delegate关键字,没有方法体{}的方法模版(方法列表);委托是一种类型 public void Write() { //TODO } //加上关键字delegate,去掉方法体{} ...

  10. Nagios+InfluxDB+Grafana

    1. 概述 Nagios负责收集数据,是一款开源的免费网络监视工具. influxDB负责存储数据,是一个开源的时间序列数据库.比较适合存储监控或者部署记录这些时序数据. Grafana负责数据的图形 ...