android - 使用 appium 和 python 的 android 应用程序的功能测试

标签 android python automation functional-testing python-appium

这是用于检查录音是否正常的 python 代码:

   def setUp(self):"Setup for the test"
       desired_caps = {}
       desired_caps['browserName']=''
       desired_caps['platformName'] = 'Android'
       desired_caps['platformVersion'] = '4.4.2'
       desired_caps['deviceName'] = 'd65d04425101de'
       # Returns abs path relative to this file and not cwd
       desired_caps['app'] = '/home/karthik/appiumworkspace/tests/app-debug (2).apk'
       desired_caps['appPackage'] = 'com.prueba.maverick'
       desired_caps['app-activity'] = '.SplashActivity' 
       desired_caps['app-wait-activity'] = '.MainActivity' 
       self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

   def tearDown(self):
       "Tear down the test"
       self.driver.quit()


    def test_whether_app_is_installed(self):
        "Test if the app has been installed correctly"
        self.driver.is_app_installed('com.prueba.maverick')

        print('APP HAS BEEN INSTALLED')


    def test_record_the_audio(self):
       "Test it clicks on Record button correctly"
        element = WebDriverWait(self.driver, 15).until(EC.presence_of_element_located((By.NAME, "PRESS TO RECORD")))
        element.click()
        time.sleep(10)
        element = WebDriverWait(self.driver, 15).until(EC.presence_of_element_located((By.NAME, "RECORDING PRESS TO STOP")))
        element.click()
        print('AUDIO RECORDED SUCCESSFULLY')        

   if __name__ == '__main__':
       suite = unittest.TestLoader().loadTestsFromTestCase(MaverickAndroidTests)
       unittest.TextTestRunner(verbosity=2).run(suite)

到这里为止一切正常..

现在我必须检查物理设备,录音是否真的存在..

我必须转到设备文件管理器,检查是否存在录制的音频 (recording.mp3)

我该如何编写测试用例??

最佳答案

您可以打开文件管理器应用程序并导航至应用程序文件夹并检查该文件夹中是否存在recording.mp3文件。

关于android - 使用 appium 和 python 的 android 应用程序的功能测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35884580/

相关文章:

Android 在应用程序启动时启动系统服务

pdf - 使用 Applescript 进行 Photoshop 脚本编写 - 在没有提示的情况下不会打开图像

java - 如果别的??尝试??我需要方法方面的帮助

python - 根据日期排列 Dataframe 中的数据

python - py脚本从mysql数据库写入xlsx文件

Excel 自动化。需要从范围中选择多个项目

android - 我无法在 macOS Sierra 上安装英特尔 HAXM

android - Eclipse Helios Android模拟器如何运行示例工程

java - 我需要帮助破译这个错误,我正在尝试填充 ListView

python - 具有关系的 SQLAlchemy 继承在实例化对象中为 None