jenkins+appium android app自动化测试
mac安装https://www.jianshu.com/p/8eee4b73db24
windows安装
jenkins安装
新建任务
其他默认,保存
立即构建
test_login.py
from src.pages import login_page, module_page from src.common import driver_configure, gesture_operator import unittest import time import warnings import os from config.globalparameter import login_name, login_password # import pytest # import allure # from src.test_case import startAppiumServer class Test_appium(unittest.TestCase): @classmethod def setUpClass(cls): # 启动appium # appium_operator.start_AppiumS('23') # os.system('start /b startAppiumServer.bat') # start /b appium日志会输出至控制台,而不显示在cmd窗口 # os.system('start startAppiumServer.bat') # start appium日志会不会输出至控制台,而是显示在cmd窗口 os.system('start /b appium -a 127.0.0.1 -p 4723') time.sleep(15) # 等待appium启动 warnings.simplefilter("ignore", ResourceWarning) dconfigur = driver_configure.Driver_configure() cls.driver = dconfigur.get_driver() cls.GM = gesture_operator.Gesture_mainpulation() # 手势 @classmethod def tearDownClass(cls): # driver_configure.Driver_configure().get_driver().quit() #退出 # os.system("start /b stopAppiumServer.bat") os.system("start /b taskkill /F /IM node.exe") # pass # 登陆 def test_login(self): print("登录!") time.sleep(1) self.login_page = login_page.login_page(self.driver) self.login_page.input_user(login_name) self.login_page.input_Pws(login_password) self.login_page.click_btnLogin() # self.driver.find_element_by_id('com.zhijiepay.android:id/but_OK').click() # 设置隐式等待时间 self.driver.implicitly_wait(3) time.sleep(5) def test_module(self): self.module_page = module_page.Module_page(self.driver) self.module_page.click_btn_sy() self.module_page.click_side_goods() if __name__ == '__main__': # pytest.main("-v test_login.py") unittest.main() # suite = unittest.TestSuite() # suite.addTest(Test_appium('test_login'))
完整代码可参考
setUpClass() 启动appium时,本来使用的是.bat文件(在pycharm运行时可直接运行),但在jenkins立即构建时提示找不到文件“startAppiumServer.bat”
目前还不知道怎么处理,但把启动操作直接写入脚本中,可正常运行