使用appium和python的android应用程序的功能测试 [英] Functional test of an android app using appium and python

查看:137
本文介绍了使用appium和python的android应用程序的功能测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是检查录制是否正常的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)

在这里工作正常.

现在,我必须检查物理设备,是否确实存在记录.

Now I have to check in the physical device, whether the recording is actually present or not..

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

I have to go to the device File Manager, to check for the presence of the recorded audio (recording.mp3)

我如何为此编写测试用例?

How can I write the test case for that ??

推荐答案

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

You can open the File Manager app and navigate to the app folder and check for the presence of recording.mp3 file in that folder.

这篇关于使用appium和python的android应用程序的功能测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆