Appium 菜鸟一只,求问在 IOS 环境下运行 python 脚本,无论是在模拟器上还是真机上,都感觉速度很慢,比手动操作还要慢好多,简直不能忍。Mac,Xcode,Appium 的版本都是最新的。有什么设置可以加快运行速度吗?请大神指教。
之前用 Mac 自带的 UIAutomator 生成 JavaScript, 跑起来速度很快的。
Python 脚本如下:
import os
from random import randint
from appium import webdriver
from time import sleep
success = True
desired_caps = {}
desired_caps['appium-version'] = '1.0'
desired_caps['platformName'] = 'iOS'
desired_caps['platformVersion'] = '8.1'
desired_caps['deviceName'] = 'iPhone 5'
desired_caps['app'] = os.path.abspath('/Users/pod/Downloads/appium_test_sample/sample-code-master/sample-code/apps/TestApp/build/Release-iphonesimulator/TestApp.app')
wd = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
wd.implicitly_wait(60)
def is_alert_present(wd):
try:
wd.switch_to_alert().text
return True
except:
return False
try:
wd.get_screenshot_as_file("/Users/pod/Downloads/appium_test_sample/sample-code-master/sample-code/apps/TestApp/screenshot/begin1.png")
wd.find_element_by_name("IntegerA").click()
wd.find_element_by_name("more, numbers").click()
wd.find_element_by_name("1").click()
wd.find_element_by_name("2").click()
wd.find_element_by_name("3").click()
wd.find_element_by_name("4").click()
wd.find_element_by_name("IntegerB").click()
wd.find_element_by_name("more, numbers").click()
wd.find_element_by_name("8").click()
wd.find_element_by_name("9").click()
wd.find_element_by_name("1").click()
wd.find_element_by_name("5").click()
wd.find_element_by_name("ComputeSumButton").click()
wd.find_element_by_name("show alert").click()
wd.find_element_by_xpath("//UIAApplication[1]/UIAWindow[4]/UIAAlert[1]/UIACollectionView[1]/UIACollectionCell[2]/UIAButton[1]").click()
wd.find_element_by_name("Done").click()
wd.find_element_by_name("Test Gesture").click()
wd.get_screenshot_as_file("/Users/pod/Downloads/appium_test_sample/sample-code-master/sample-code/apps/TestApp/screenshot/end1.png")
finally:
wd.quit()
if not success:
raise Exception("Test failed.")