• python-appium520-3引入unittest,编写自动化用例


    unittest是python的测试框架,和junit相似。
    test.py

    import unittest
    
    class Apptest(unittest.TestCase):
        def setUp(self):
            print("prepare")
        def tearDown(self):
            print("cleanup")
        def test_c(self):
            print("testc")
        def test_a(self):
            print("test a")
        def test_b(self):
            print("test b")
    if __name__=="__main__":
        unittest.main()
    

    引入unittest

    test2.py

    import unittest
    from appium import webdriver
    from time import sleep
    
    class Apptest(unittest.TestCase):
        def setUp(self):
            caps = {}
            caps["platformName"] = "android"
            caps["deviceName"] = "domo"
            caps["appPackage"] = "com.xueqiu.android"
            caps["appActivity"] = ".view.WelcomeActivityAlias"
            caps["newCommandTimeout"] = 600
            caps["automationName"] = "UiAutomator2"
    
            self.driver = webdriver.Remote("http://localhost:4723/wd/hub", caps)
            self.driver.implicitly_wait(20)
            sleep(20)
        def tearDown(self):
            self.driver.quit()
        def test_c(self):
            print(self.driver.session_id)
        def test_a(self):
            self.driver.find_element_by_id("com.xueqiu.android:id/user_profile_icon").click()
            sleep(1)
            self.driver.find_element_by_id("com.xueqiu.android:id/tv_login").click()
            sleep(1)
            self.driver.find_element_by_id("com.xueqiu.android:id/tv_login_by_phone_or_others").click()
            sleep(1)
            self.driver.find_element_by_id("com.xueqiu.android:id/register_phone_number").send_keys("123456789")
            sleep(3)
            print(self.driver.session_id)
        def test_b(self):
            print("test b")
    if __name__=="__main__":
        unittest.main()
    
  • 相关阅读:
    上传并压缩图片
    C#使用一般处理程序(ashx)中session
    cookie记住用户名密码
    操作数组
    鼠标滚轮事件兼容写法
    table嵌套table,jquery获取tr个数
    网站性能调优实战-学相伴KuangStudy
    为什么fdisk分区第一个分区以63或者2048扇区开始?
    oracle分组查询,获取组内所有信息(拼接显式)
    oracle中对象类型搜集(object type)
  • 原文地址:https://www.cnblogs.com/csj2018/p/9740462.html
Copyright © 2020-2023  润新知