Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/352.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何正确使用Python在AmazonWeb服务上进行自动化测试_Android_Python_Amazon Web Services_Automation_Appium - Fatal编程技术网

Android 如何正确使用Python在AmazonWeb服务上进行自动化测试

Android 如何正确使用Python在AmazonWeb服务上进行自动化测试,android,python,amazon-web-services,automation,appium,Android,Python,Amazon Web Services,Automation,Appium,我说西班牙语,对不起我的英语。我有一个移动应用程序,我想使用aws设备场进行自动化测试。我在Mac电脑上,我正试图在我的Android应用程序上做一个简单的测试:点击登录按钮,输入用户名和密码,然后登录。 我使用appium为我的测试准备了一个python代码,然后我将我的.apk和一个带有测试的zip文件上传到aws,但它总是失败。我是python新手,我找不到一个对我有帮助的例子 我遵循上面的所有步骤,但运行测试只会失败,不会截图 这是.py代码: from selenium.web

我说西班牙语,对不起我的英语。我有一个移动应用程序,我想使用aws设备场进行自动化测试。我在Mac电脑上,我正试图在我的Android应用程序上做一个简单的测试:点击登录按钮,输入用户名和密码,然后登录。 我使用appium为我的测试准备了一个python代码,然后我将我的.apk和一个带有测试的zip文件上传到aws,但它总是失败。我是python新手,我找不到一个对我有帮助的例子

我遵循上面的所有步骤,但运行测试只会失败,不会截图

这是.py代码:

    from selenium.webdriver.firefox.webdriver import WebDriver
    from selenium.webdriver.common.action_chains import ActionChains
    import time
    import os.path
    import unittest
    from selenium import webdriver

    success = True
    desired_caps = {}
    desired_caps['appium-version'] = '1.0'
    desired_caps['platformName'] = 'Android'
    desired_caps['platformVersion'] = '5.0.1'
    desired_caps['app'] = os.path.abspath('/Users/developer/Documents/AWS/workspace/APK/Squeeze.apk')
    desired_caps['appPackage'] = 'com.example.mkim.aut'
    desired_caps['appActivity'] = 'com.example.mkim.aut.SuccessfulLogin'

    wd = webdriver.Remote('http://0.0.0.0:4723/wd/hub', desired_caps)
    wd.implicitly_wait(60)

    screenshot_folder = os.getenv('SCREENSHOT_PATH', '')
    wd.save_screenshot(screenshot_folder + "/screenshot.png")


   def is_alert_present(wd):
       try:
           wd.switch_to_alert().text
           return True
       except:
           return False

   try:
       #self.driver.save_screenshot(screenshot_folder + "/screenshot.png")
       wd.execute_script("mobile: tap", {"tapCount": 1, "touchCount": 1, "duration": 0.5, "x": 666, "y": 1519 })
       wd.save_screenshot(screenshot_folder + "/screenshot1.png") 
       wd.find_element_by_xpath("//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.webkit.WebView[1]/android.webkit.WebView[1]/android.view.View[1]/android.view.View[1]").click()
       wd.execute_script("mobile: tap", {"tapCount": 1, "touchCount": 1, "duration": 0.5, "x": 121, "y": 726 })
       wd.find_element_by_name("(null)").send_keys("Squeeze@mailinator.com")
       wd.execute_script("mobile: tap", {"tapCount": 1, "touchCount": 1, "duration": 0.5, "x": 191, "y": 919 })
       wd.find_element_by_name("(null)").send_keys("Password")
       wd.execute_script("mobile: tap", {"tapCount": 1, "touchCount": 1, "duration": 0.5, "x": 563, "y": 1079 })
   except:
          wd.quit()
          if not success:
               raise Exception("Test failed.")

我为AWS设备场团队工作

你提到你正在使用Mac电脑。根据说明,如果Linux x86_64机器包含非通用控制盘,则应使用该机器打包测试。此外,您还需要确保没有任何具有本机库依赖项的控制盘

您应该能够使用命令在本地环境中成功检测测试

py.test-仅收集测试/

您的代码显示您正在设置所需的功能。由于您已经选择了要在设备场中运行测试的设备和操作系统版本,因此您希望从代码中删除这些所需的功能。只需要有一个空的期望功能对象,它被传递给驱动程序构造函数

所需的_caps={}

您的驱动程序构造函数需要使用

wd=webdriver.Remote,所需的\u caps

屏幕截图代码必须是

screenshot\u folder=os.getenv'screenshot\u PATH','/tmp'

最后,请确保您的代码在本地运行,并且按照说明,在wheelhouse文件夹下没有任何控制盘,其中存在命名的依赖项

你尝过吗?