当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. Centos7下安装与卸载Jdk1.8

    安装 去官网下载jdk:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 使用xs ...

  2. ThinkPhp 生成静态页面

    //开启静态缓存'HTML_CACHE_ON' => true, //开启缓存'HTML_CACHE_TIME' =>60, //开启缓存时间'HTML_FILE_SUFFIX' => ...

  3. C# 释放资源的规范写法

    static class CSharp_3 { /* ---------------------------------------- * 以下学习资源的释放:IDispose和析构函数 * 1.ID ...

  4. PreTranslateMessage()函数捕获键盘按键消息

    01. PreTranslateMessage函数,常用于屏蔽MFC对话框中默认的Enter和ESC消息 函数原型:BOOL PreTranslateMessage(MSG* pMsg) 用法举例: ...

  5. oracle数据库sqlldr命令的使用

    将数据导入 oracle 的方法应该很多 , 对于不同需求有不同的导入方式 , 最近使用oracle的sqlldr命令 导入数据库数据感觉是个挺不错的技术点 .  使用sqlldr命令 将文本文件导入 ...

  6. [LeetCode 题解]: Insertion Sort List

    Sort a linked list using insertion sort. 题目要求:链表的插入排序,由于没有时间复杂度的要求,可以直接循环操作. /** * Definition for si ...

  7. C# javascript 采用 RSA 加密解密

    C# javascript 采用 RSA 加密解密 1.C#提供公钥 2.javascript用公钥加密 3.C#用私钥解密 4.javascript 类库 https://www.pidder.de ...

  8. jenkins+checkstyle

    一.新增一个自由风格的项目 建好之后如下图所示 二.修改pom.xml文件 在项目根目录下添加如下代码(此处添加的3个插件) <build> <plugins> <plu ...

  9. 在 Mac OSX 上安装 nginx

    今天在使用 brew 安装 nginx 时,提示错误,安装不上去: brew install nginx, 提示:/usr/local is not writable. 这个是需要修改 /usr/lo ...

  10. [Perl]Windows 系统 Unicode 文件名操作(新建、重命名、枚举、复制)全攻略

    [Perl] Windows 系统 Unicode 文件名操作(新建.重命名.枚举.复制)全攻略 环境 XP/WIN7 Perl v5.16 编辑整理:PerlMonk.523066680 常见的那些 ...