使用python编写appium用例
来源:互联网 发布:windows文件恢复大师 编辑:程序博客网 时间:2024/06/07 13:34
安装Python依赖
pip3.4 install nosepip3.4 install seleniumpip3.4 install Appium-Python-Client
运行测试用例android_contacts.py
import osimport unittestfrom appium import webdriverfrom time import sleep# Returns abs path relative to this file and not cwdPATH = lambda p: os.path.abspath( os.path.join(os.path.dirname(__file__), p))class ContactsAndroidTests(unittest.TestCase): def setUp(self): desired_caps = {} desired_caps['platformName'] = 'Android' desired_caps['platformVersion'] = '4.4' desired_caps['deviceName'] = '192.168.56.111:5555' desired_caps['app'] = PATH( '../../../sample-code/apps/ContactManager/ContactManager.apk' ) desired_caps['appPackage'] = 'com.example.android.contactmanager' desired_caps['appActivity'] = '.ContactManager' self.driver = webdriver.Remote('http://0.0.0.0:4723/wd/hub', desired_caps) def tearDown(self): self.driver.quit() def test_add_contacts(self): el = self.driver.find_element_by_name("Add Contact") el.click() textfields = self.driver.find_elements_by_class_name("android.widget.EditText") textfields[0].send_keys("Appium User") textfields[2].send_keys("someone@appium.io") self.assertEqual('Appium User', textfields[0].text) self.assertEqual('someone@appium.io', textfields[2].text) self.driver.find_element_by_name("Save").click() # for some reason "save" breaks things alert = self.driver.switch_to_alert() # no way to handle alerts in Android self.driver.find_element_by_android_uiautomator('new UiSelector().clickable(true)').click() self.driver.keyevent(3)if __name__ == '__main__': suite = unittest.TestLoader().loadTestsFromTestCase(ContactsAndroidTests) unittest.TextTestRunner(verbosity=2).run(suite)
运行用例结果:
bixiaopeng@bixiaopengtekiMacBook-Pro python$ python3.4 android_contacts.py test_add_contacts (__main__.ContactsAndroidTests) ... ok----------------------------------------------------------------------Ran 1 test in 17.214sOK
微信公众帐号: wirelessqa
关于作者:
作者: 毕小朋 | 老 毕 邮箱: wirelessqa.me@gmail.com
微博: @WirelessQA 博客: http://blog.csdn.net/wirelessqa
4 0
- 使用python编写appium用例
- 使用python编写appium用例
- 用idea编写appium用例
- 用idea编写appium用例
- 用idea编写appium用例
- 用idea编写appium用例
- appium python api使用实例
- Appium 使用 Python 运行 Appium 测试的示例
- appium的python脚本编写前准备(三)
- 使用python实现appium的屏幕滑动
- appium-python
- 使用Eclipse编写Python
- appium+python测试app使用相对坐标定位元素
- 使用appium+python对android进行自动化测试
- appium+python学习笔记之使用HTMLTestRunner.py生成测试报告
- iOS+APPIUM+Python部署
- appium+python实例
- Appium python 框架
- oracle优化
- 分享一个中国领先的.Net论坛http://bbs.netluntan.com
- 用idea编写appium用例
- 浙江大华浙大2010年校园招聘笔试试题
- 链表类型list和foreard_list的特定容器算法
- 使用python编写appium用例
- ExtJs中Store简介(秘籍)
- Subsets II
- 利用cmd打开文件
- 《Javascript高级程序设计》第十三章——事件学习笔记(待续)
- ext中ArrayStore,JsonStore,XmlStore的用
- Compiling HTK 3.4 on Mac OS 10.5
- winform网络编程之TcpClient类,TcpListener类和UdpClient类
- 个人写的一个函数,高手勿喷