- hosts: all
vars:
contents: ""
tasks:
- debug: msg="the value of foo.txt is "
import os
import appium.webdriver
webdriver = appium.webdriver
# Returns abs path relative to this file and not cwd
PATH = lambda p: os.path.abspath(
os.path.join(os.path.dirname(__file__), p)
)
desired_caps = {}
desired_caps['deviceName'] = 'TestApp'
desired_caps['platformName'] = 'Android'
# desired_caps['browserName'] = 'browser'
#desired_caps['version'] = '5.0.2'
desired_caps['app'] = PATH('/Users/ml/dev/appium/ContactManager.apk')
desired_caps['app-package'] = 'com.example.android.contactmanager'
desired_caps['app-activity'] = '.ContactManager'
desired_caps["platformVersion"] = "5.0.2"
desired_caps["noReset"] = True
#desired_caps["chromeOptions"] = {"args": ['--disable-popup-blocking']}
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
el = driver.find_element_by_id("Add Contact")
el.click()
textfields = driver.find_element_by_id("com.example.android.contactmanager:id/contactNameEditText")
print('textfileds: ')
print(textfields)
print('\n')
print('its methods: ')
print(dir(textfields))
textfields.send_keys(["My Name"])
#textfields[2].send_keys("someone@somewhere.com")
driver.find_element_by_id("Save").click()
driver.quit()
Message: Parameters were incorrect. We wanted {"required":["value"]} and you sent ["text","sessionId","id","value"]
降级selenium后解决:
appium --session-override
desired_caps['noReset'] = True
or
--no-reset for appium
Mac OS上的路径在SDK中:
/Users/ml/Library/Android/sdk/tools/bin/uiautomatorviwer
可以链接为全局命令:
sudo ln -s /Users/ml/Library/Android/sdk/tools/bin/uiautomatorviwer /usr/local/bin/uiautomaterviewer
点击Device Screenshot(uiautomater dump),稍后便会连接模拟器中正在运行的应用。
下载Android SDK、JDK、
check java home at Mac os
/usr/libexec/java_home -v
# bash_profile
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$JAVA_HOME/bin:$PATH
export CLASS_PATH=$JAVA_HOME/lib