Appium+Python實(shí)現(xiàn)簡(jiǎn)單的自動(dòng)化登錄測(cè)試的實(shí)現(xiàn)
前言
要想讓手機(jī)app自動(dòng)登錄,也就是讓app自己操作。所以在腳本中我們需要對(duì)app控件進(jìn)行操作,那么我們需要獲取控件的信息??梢允褂?.\android-sdk-windows\tools目錄下的uiautomatorviewer.bat來獲取控件相關(guān)信息
獲取控件相關(guān)信息
啟動(dòng)uiautomatorviewer.bat
打開手機(jī)app,例如計(jì)算器,USB連接電腦,點(diǎn)擊uiautomatorviewer左上角的安卓機(jī)器人按鈕Devices Screenshot按鈕刷新頁(yè)面
定位元素:移動(dòng)鼠標(biāo)到需要定位的元素上,如數(shù)字7。右下角可以看到元素對(duì)應(yīng)的屬性
登錄腳本實(shí)現(xiàn)
# coding=utf-8 __author__ = "Enoch" # 這是一個(gè)app登錄的測(cè)試 from appium import webdriver from HTMLTestRunner import HTMLTestRunner import unittest import time import warnings class LoginTest(unittest.TestCase): def setUp(self): warnings.simplefilter("ignore", ResourceWarning) desired_caps = { 'platformName': 'Android', 'deviceName': 'SGEEGEHIQ8I7CIKF', 'platformVersion': '6.0', 'appPackage': 'com.mengtuiapp.mall', 'appActivity': '.business.main.MainActivity' } self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps) def testCase(self): u"""登錄""" driver = self.driver # time.sleep(2) driver.find_element_by_id("bottom_nav").click() time.sleep(2) driver.find_element_by_name('使用其他方式登錄').click() driver.find_element_by_name('手機(jī)登錄').click() driver.find_element_by_id("username").send_keys("13100010001") driver.find_element_by_name('獲取驗(yàn)證碼').send_keys("9876") driver.find_element_by_id("btn").click() driver.quit() if __name__ == '__main__': print("----------執(zhí)行---------- ") suite = unittest.TestSuite() # 構(gòu)造測(cè)試集 suite.addTest(LoginTest('testCase')) # 定義自動(dòng)化報(bào)告目錄 filename = "F:\\report.html" fp = open(filename, 'wb') runner = HTMLTestRunner( stream=fp, title=u'自動(dòng)化測(cè)試報(bào)告', description=u'這是登錄測(cè)試的簡(jiǎn)單報(bào)告' ) runner.run(suite) fp.close()
到此這篇關(guān)于Appium+Python實(shí)現(xiàn)簡(jiǎn)單的自動(dòng)化登錄測(cè)試的實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)Appium Python自動(dòng)化登錄測(cè)試內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- python+pytest接口自動(dòng)化之token關(guān)聯(lián)登錄的實(shí)現(xiàn)
- Python接口自動(dòng)化淺析登錄接口測(cè)試實(shí)戰(zhàn)
- python+opencv+selenium自動(dòng)化登錄郵箱并解決滑動(dòng)驗(yàn)證的問題
- Python GUI自動(dòng)化實(shí)現(xiàn)繞過驗(yàn)證碼登錄
- python自動(dòng)化實(shí)現(xiàn)登錄獲取圖片驗(yàn)證碼功能
- Selenium+Python 自動(dòng)化操控登錄界面實(shí)例(有簡(jiǎn)單驗(yàn)證碼圖片校驗(yàn))
- selenium+python實(shí)現(xiàn)自動(dòng)化登錄的方法
- Python自動(dòng)化測(cè)試之登錄腳本的實(shí)現(xiàn)
相關(guān)文章
Python 多進(jìn)程和數(shù)據(jù)傳遞的理解
這篇文章主要介紹了Python 多進(jìn)程和數(shù)據(jù)傳遞的理解的相關(guān)資料,希望通過本文能幫助到大家,需要的朋友可以參考下2017-10-10Numpy中的數(shù)組搜索中np.where方法詳細(xì)介紹
這篇文章主要介紹了Numpy中的數(shù)組搜索中np.where方法詳細(xì)介紹,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-01-01