#coding=utf-8 import sys sys.path.append('D:\\PythonAppium') import os from appium import webdriver import unittest import time class BaseDriver: def get_driver(self): capablities = { 'platformName':'Android', 'deviceName':'I76PBE4D45EADQSS', 'appActivity':'.activity.MainActivity_', 'appPackage':'com.yek.android.game5173' } time.sleep(10) driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub',capablities) return driver def start_server(self): command = 'appium -p 4723 -bp 4724 -U I76PBE4D45EADQSS --no-reset --session-override' os.system(command) class CaseTest(unittest.TestCase): def setUp(self): time.sleep(10) self.base_driver = BaseDriver() self.driver = self.base_driver.get_driver() time.sleep(20) def test_case(self): time.sleep(8) self.driver.find_elements_by_id('com.yek.android.game5173:id/iv_hotgame')[0].click() time.sleep(5) self.driver.find_elements_by_class_name('android.view.View')[25].click() time.sleep(5) def tearDown(self): time.sleep(5) def appium_init(): base_driver = BaseDriver() base_driver.start_server() time.sleep(30) if __name__ == '__main__': appium_init() suite = unittest.TestSuite() suite.addTest(CaseTest("test_case")) unittest.TextTestRunner().run(suite)
运行上面的代码,appium能起来,但是却不执行用例,也不报错,不知道怎么解决。
运行结果如下: