appium整理文档

简介: 笔记

利用一天时间去整理appium for android文档。传送门

文中代码如下展示。

from appium import webdriver
import time,unittest,HTMLTestRunner
class Testlogin(unittest.TestCase):
    def setUp(self):
        self.desired_caps={}
        self.desired_caps['platformName'] = 'Android'
        self.desired_caps['deviceName']='a6969'
        self.desired_caps['preformVersion']='5.0.2'
        self.desired_caps['appPackage'] = 'com.tencent.mobileqq'
        self.desired_caps['appActivity'] ='.activity.SplashActivity'
        self.driver=webdriver.Remote('http://localhost:4723/wd/hub', self.desired_caps)
        time.sleep(2)
    def tearDown(self):
        self.driver.find_element_by_id('com.tencent.mobileqq:id/conversation_head').click()
        self.driver.find_element_by_id('com.tencent.mobileqq:id/settings').click()
        self.driver.find_element_by_id('com.tencent.mobileqq:id/account_switch').click()
        self.driver.find_element_by_id('com.tencent.mobileqq:id/logoutBtn').click()
        self.driver.find_element_by_id('com.tencent.mobileqq:id/dialogRightBtn').click()
        self.driver.quit()
    def testLogin1(self):
        self.driver.find_element_by_id('com.tencent.mobileqq:id/btn_login').click()
        time.sleep(2)
        me=self.driver.find_element_by_android_uiautomator('new UiSelector().text("QQ号/手机号/邮箱")')
        me.clear()
        me.send_keys('319197149')
        password=self.driver.find_element_by_id('com.tencent.mobileqq:id/password')
        password.clear()
        password.send_keys('lileilei.930423')
        self.driver.find_element_by_id('com.tencent.mobileqq:id/login').click()
        m=self.driver.find_element_by_id('com.tencent.mobileqq:id/conversation_head')
        if m is not None:
            print('login is sucess')
        else:
            print('login is Flase')
            print(self.driver.find_element_by_id('com.tencent.mobileqq:id/dialogText').text)
if __name__ == '__main__':
    suiteTest = unittest.TestSuite()
    suiteTest.addTest(Testlogin("testLogin1"))
    now=time.strftime('%Y-%m%d',time.localtime(time.time()))
    report_dir= r'%s.html'%now
    re_open= open(report_dir,'wb')
    runner=HTMLTestRunner.HTMLTestRunner(stream=re_open,title='QQ测试',description='测试结果')
    runner.run(suiteTest)
相关文章
|
5月前
|
XML Java 测试技术
『App自动化测试之Appium应用篇』| 元素定位工具Appium-Inspector从简介、安装、配置到使用的完整攻略
『App自动化测试之Appium应用篇』| 元素定位工具Appium-Inspector从简介、安装、配置到使用的完整攻略
181 3
|
5月前
|
JavaScript Java 测试技术
『App自动化测试之Appium基础篇』| 从定义、原理、环境搭建、安装问题排查等深入了解Appium
『App自动化测试之Appium基础篇』| 从定义、原理、环境搭建、安装问题排查等深入了解Appium
692 0
|
6天前
|
测试技术 API Python
Appium控件交互策略:优化自动化测试效率的关键方法
该文介绍了如何使用Selenium与APP进行交互,包括点击、输入和状态判断等操作。例如,通过element.click()点击控件,element.send_keys()输入文本,以及element.is_displayed()检查元素是否可见。还展示了如何获取元素属性,如resource-id、text和class,并提供了Python代码示例来定位并操作APP元素,如滑动条的显示、可点击性检测及点击滑动条中心位置。在编写测试脚本时,应注意元素定位和状态验证以确保测试稳定性。
13 1
|
5月前
|
编解码 Java 测试技术
『App自动化测试之Appium应用篇』| uiautomator + accessibility_id定位方法完全使用攻略
『App自动化测试之Appium应用篇』| uiautomator + accessibility_id定位方法完全使用攻略
130 0
|
5月前
|
XML 测试技术 开发工具
『App自动化测试之Appium应用篇』| 元素定位工具uiautomatorviewer从简介、特点、启动到使用的完整过程
『App自动化测试之Appium应用篇』| 元素定位工具uiautomatorviewer从简介、特点、启动到使用的完整过程
84 4
|
1天前
|
中间件 测试技术 API
探索自动化测试工具的新边界:Selenium与Appium的集成实践
【4月更文挑战第30天】 随着移动应用和Web应用的不断融合,传统的自动化测试工具需要适应新的测试环境。本文将详细分析Selenium和Appium这两款流行的自动化测试工具的集成实践,探讨如何构建一个能够同时支持Web和移动端应用的自动化测试框架。通过对比两者的技术架构、功能特性以及在实际项目中的集成过程,我们旨在为读者提供一个清晰的指导,帮助他们在复杂的应用环境中实现高效、稳定的自动化测试流程。
|
2天前
|
前端开发 JavaScript 测试技术
深入探索自动化测试框架:Selenium与Appium的对比分析
【4月更文挑战第29天】 在快速迭代的软件发展环境中,自动化测试已成为确保软件质量和加速产品上市的关键步骤。本文将重点探讨两种广泛使用的自动化测试框架——Selenium和Appium,通过对比它们的核心特性、适用场景及执行效率,为软件开发和测试团队提供选择指南。文章不仅分析了各自的技术架构和脚本语言支持,还讨论了它们在处理Web应用和移动应用测试时的优缺点,旨在帮助读者根据项目需求做出更加明智的选择。
|
5月前
|
移动开发 安全 测试技术
『App自动化测试之Appium应用篇』| 继承于selenium常用的元素定位方法有哪些?如何使用?
『App自动化测试之Appium应用篇』| 继承于selenium常用的元素定位方法有哪些?如何使用?
87 0
|
5月前
|
测试技术 Android开发 iOS开发
『App自动化测试之Appium基础篇』| Desired Capabilities详解与使用
『App自动化测试之Appium基础篇』| Desired Capabilities详解与使用
85 0