【发布时间】:2016-07-10 23:34:29
【问题描述】:
我说西班牙语,对不起我的英语。我有一个移动应用程序,我想使用 aws device farm 进行自动化测试。我在 Mac 上,正在尝试对我的 Android 应用程序进行简单测试:点击登录按钮,输入用户名和密码,然后登录。 我正在使用 appium 为我的测试提供一个 python 代码,然后我将我的 .apk 和一个带有我的测试的 zip 文件上传到 aws,但它总是失败。我是 python 新手,找不到对我有帮助的示例。
我按照http://docs.aws.amazon.com/es_es/devicefarm/latest/developerguide/test-types-android-appium-python.html 上的所有步骤进行操作,但运行测试只会失败且不截屏。
这是 .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.")
【问题讨论】:
标签: android python amazon-web-services automation appium