使用Appium操作YY語音例子

來源:互聯網
上載者:User

標籤:self   ret   launch   命令   UI   devices   client   build   mission   

#!/usr/bin/env python # -*- coding: utf-8 -*-import osimport unittestfrom appium import webdriverimport time# Returns abs path relative to this file and not cwdPATH = lambda p: os.path.abspath(    os.path.join(os.path.dirname(__file__), p))class YY(unittest.TestCase):    def setUp(self):        desired_caps = {            ‘platformName‘: ‘Android‘,            ‘deviceName‘: ‘611AKBPP22HR5‘,  # adb devices查到的裝置名稱            ‘platformVersion‘: ‘4.4.2‘,            ‘appPackage‘: ‘com.duowan.mobile‘,  # 被測App的包名            ‘appActivity‘: ‘com.yy.mobile.ui.splash.SplashActivity‘,# 啟動時的Activity            # ‘app‘:PATH(‘E:\yymobile_client-7.7.1.apk‘)        }        self.driver = webdriver.Remote(‘http://localhost:4723/wd/hub‘,desired_caps)    def tearDown(self):        self.driver.quit()    def test_index_module(self):        self.driver.wait_activity(‘com.yy.mobile.ui.home.MainActivity‘,30)        el = self.driver.find_element_by_name("小視頻")        self.assertIsNotNone(el)        el.click()        time.sleep(3)        yueBang = self.driver.find_element_by_name("一起玩")        self.assertIsNotNone(yueBang)        yueBang.click()if __name__ == ‘__main__‘:    # suite = unittest.TestLoader().loadTestsFromTestCase(YY)    # unittest.TextTestRunner(verbosity=2).run(suite)    unittest.main()

 

查看包名與啟動activity:推薦使用aapt工具,aapt是sdk內建的一個工具,在sdk\build-tools目錄下

D:\Android\sdk\build-tools>aapt dump badging F:\ChromeDownloads\yymobile_client-7.7.1.apkpackage: name=‘com.duowan.mobile‘ versionCode=‘60513‘ versionName=‘7.7.1‘ platformBuildVersionName=‘6.0-2704002‘sdkVersion:‘14‘targetSdkVersion:‘22‘uses-permission: name=‘android.permission.ACCESS_WIFI_STATE‘......launchable-activity: name=‘com.yy.mobile.ui.splash.SplashActivity‘  label=‘‘ icon=‘‘......

查看當前activity:開啟到對應的視窗後,執行命令  adb shell dumpsys window w |findstr \/ |findstr name=

D:\Android\sdk\build-tools>adb shell dumpsys window w |findstr \/ |findstr name=      mSurface=Surface(name=com.duowan.mobile/com.yy.mobile.ui.home.MainActivity)

等待activity:driver.wait_activity,30s後逾時

self.driver.wait_activity(‘com.yy.mobile.ui.home.MainActivity‘,30)

根據name定位元素

el = self.driver.find_element_by_name("小視頻")

 

使用Appium操作YY語音例子

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.