Python unittest appium
import unittest from appium import webdriver
from appium.common.exceptions import NoSuchContextException
import desired_capabilities class ContextSwitchingTests(unittest.TestCase):
def setUp(self):
desired_caps = desired_capabilities.get_desired_capabilities('selendroid-test-app.apk')
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps) def test_contexts_list(self):
self._enter_webview()
contexts = self.driver.contexts
self.assertEqual(2, len(contexts)) def test_move_to_correct_context(self):
self._enter_webview()
self.assertEqual('WEBVIEW_io.selendroid.testapp', self.driver.current_context) def test_actually_in_webview(self):
self._enter_webview()
self.driver.find_element_by_css_selector('input[type=submit]').click()
el = self.driver.find_element_by_xpath("//h1[contains(., 'This is my way')]")
self.assertIsNot(None, el) def test_move_back_to_native_context(self):
self._enter_webview()
self.driver.switch_to.context(None)
self.assertEqual('NATIVE_APP', self.driver.current_context) def test_set_invalid_context(self):
self.assertRaises(NoSuchContextException, self.driver.switch_to.context, 'invalid name') def tearDown(self):
self.driver.quit() def _enter_webview(self):
btn = self.driver.find_element_by_name('buttonStartWebviewCD')
btn.click()
self.driver.switch_to.context('WEBVIEW') if __name__ == "__main__":
suite = unittest.TestLoader().loadTestsFromTestCase(ContextSwitchingTests)
unittest.TextTestRunner(verbosity=2).run(suite)
Python unittest appium的更多相关文章
- 从python run 和python unittest两种eclipse运行方式深入理解if __name__ == "__main__"
在写一个简单的python测试程序的时候,发现eclipse中Run as "Python run 和 Python unittest”结果不一样?为什么会不一样? 先贴一下代码段: # - ...
- 篇2 安卓app自动化测试-初识python调用appium
篇2 安卓app自动化测试-初识python调用appium --lamecho辣么丑 1.1概要 大家好!我是lamecho(辣么丑),上一篇也是<安卓app自动化测 ...
- 自动化测试神器 之 python unittest 断言
自动化测试的最后一步需要判断结果是否正确,而正确设置断言可以帮助判断测试用例的执行结果,从而提高自动化测试的效率,python unittest 提供了一个比较完整的断言方法.unittest框架测 ...
- 第二种方式,修改python unittest的执行顺序,使用猴子补丁
1.按照测试用例的上下顺序,而不是按方法的名称的字母顺序来执行测试用例. 之前的文章链接 python修改python unittest的运行顺序 之前写的,不是猴子补丁,而是要把Test用例的类名传 ...
- Python + Robotframework + Appium 之APP自动化测试小试牛刀(Android)
Robotframework如何好?这里先不说了~ Python更不用说了~ Appium前面的文章有介绍~ 今天直接来Python+Robotframework+Appium 三者结合起来,对And ...
- Appium使用Python运行appium测试的实例
Appium使用Python运行appium测试的实例 一. Appium之介绍 https://testerhome.com/topics/8038 详情参考--https://testerhom ...
- Pycharm上python unittest不执行"if __name__ == '__main__' "问题or选择非unittest run
转:http://www.cnblogs.com/csjd/p/6366535.html python unittest不执行"if __name__ == '__main__' " ...
- 简单实现接口自动化测试(基于python+unittest)
简单实现接口自动化测试(基于python+unittest) 简介 本文通过从Postman获取基本的接口测试Code简单的接口测试入手,一步步调整优化接口调用,以及增加基本的结果判断,讲解Pytho ...
- python+unittest 搭建简易的接口测试框架
主要介绍如何使用python+unittest快速搭建一个接口测试的框架 1.安装python unittest 2.新建一个python项目ApiTest 在setUp和setDown里设置一些需 ...
随机推荐
- C++ new和delete具体操作符是怎样的
在C语言中,动态分配内存用 malloc() 函数,释放内存用 free() 函数.如下所示: int *p = (int*) malloc( sizeof(int) * 10 ); //分配10个i ...
- Xstream解析XML
<oschina> <catalog>1</catalog> <newsCount>0</newsCount> <pagesize&g ...
- quick-cocos2d-x :加入学习
语法不熟悉, 接口不熟悉. 部分不理解. 超级初学者. 好好学习, 一直在学习 使用Quick-Cocos2d-x搭建一个横版过关游戏 推荐官方的文档和例子 demo
- HTML5的新增方法
json的新增方法: parse() 将JSON转换为字符串:必须是严格的JSON格式: 用法 : var s = {"name":"name"}; JSO ...
- scoi 2008 && bzoj 1076 奖励关
传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=3223 思路:15?好,状压,OK. 这是转移方程 if((s[k]&j)==s[k] ...
- 洛谷 P1007 独木桥
#include<set> #include<map> #include<cmath> #include<queue> #include<cstd ...
- Hibernate之全面认识
Hibernate体系架构 Hibernate通过配置文件管理底层的JDBC连接,将用户从原始的JDBC释放出来,使得用户无需再关注底层的JDBC操作,而是以面向对象的方式进行持久化操作.这种全面的解 ...
- discuz教程:discuz模板js与jQuery冲突的解决方案
今天在做discuz模板的时候,用到jquery的时候和原来主题js冲突.这个主要是Discuz X使用了$(id)作为dom节点的获取方法,而$符号刚好与jQuery的默认符号相冲突. 以下是基于之 ...
- LINQ的基本认识
前些日子,我的一个兄弟问我一个关于LINQ的问题,他问我AsEnumerable()在他写的一大段代码中的作用. 我不太清楚他是知道想考考我,还是不太清楚,想问题一下,反正我不太知道. 以前接触过一些 ...
- 公钥私钥和RSA算法
1, RSA算法原理(一) http://www.ruanyifeng.com/blog/2013/06/rsa_algorithm_part_one.html 2, RSA算法原理(二) http: ...