zoukankan      html  css  js  c++  java
  • 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()
    
  • 相关阅读:
    window.open
    GetPostBackClientHyperlink
    引发和使用事件
    浅谈宝宝的教育及培养
    C#关键字之:base、this
    Ioc
    自定义input[type="radio"]的样式
    选择_冒泡_直接插入排序.md
    Tkinter.md
    从零开始学wordpress 之一
  • 原文地址:https://www.cnblogs.com/csj2018/p/9740462.html
Copyright © 2011-2022 走看看