Fix issue where we might try and uninstall an ssl cert from a real device where this isn't sensible
Fix another issue with acceptSslCerts where it might potentially miss the correct sim UDID
主要是更新了 wda 的版本, 以及 xpath 的性能提升. 其实如果想用新版本绕过 appium 直接用 wda 也没啥.
Upgrade version of WebDriverAgent used. Includes following updates:
Improve xpath query performance
Verify predicates
Fix crash for some xpath selectors
Decorate proxied getSession response with Appium's capabilities (fixes issues with clients that call getSession to determine server capabilities and are confused by WDA's non-standard response) (#7480)
Fix issue with starting XCUITests on a real device, due to changes in WDA that invalidated our startup detection logic. (#7313)
Allow connecting to an already-running WebDriverAgent through the webDriverAgentUrl capability, rather than starting our own
Fix bug where we would attempt to get target SDK version from manifests even when they might not include it. (#7353)
Actually pass the acceptSslCerts capability to the underlying automation so that it can have an effect (#7326)
Updated permission granting logic to speed up permission granting by doing it in bulk rather than one at a time (#7493)
Hide the new permission granting logic behind an autoGrantPermissions capability which doesn't attempt to grant permissions unless it's true (#7497)
这个是之前很多人关注的功能, 大家可以测试下看看. selendroid 早就知道了, 这算是 uiautomator2 第一次支持吧
Add ability to verify TOAST messages (these can't be interacted with, only text retrieval allowed)
支持 windows 的自动化, 比上版本增强了
Actually upgrade WinAppDriver to 0.7 (#7445). Includes following updates:
Click on arbitrary elements
Support for sendKeys modifiers
Various bugfixes
Added GET /orientation
Added support for WPF apps
期待分享
#4 楼 @gz19891020 twitter 上看到作者发推了 觉得新增的功能不错 就转过来了 对我的遍历也很有用。我还没测试哪
刚装了,运行就报错:
Unable to start WebDriverAgent: Error: Command 'idevicedate -u a58bdd10033efffd5261d606ec221744c973b6d9' exited with code 255
有没有遇到这种情况的
所以验证 toast 是用 uiautomator2 咯,印象中 uiautomator2 是编成 APK 执行的,和 uiautomator 的 jar 方式不一样的,所以在 capabilities 设置上会不一样了吗?
怎么使用呢? 1.6.3 的 appium 源码下载回来怎么使用呢,怎么获取 toast 呢? 求指导啊
#10 楼 @zhangzhao_lenovo
感谢,这个 javascript 的 demo 直是不错,顺便请教一下,这个例子中的 await 是必须加入的吗?是为了解决什么问题吗?我对 javascript 不太了解
uiautomator 和 uiautomator2 是不是不是一个东西
—— 来自 TesterHome 官方 安卓客户端
@luobs 顶, 解决了么
python client 没有对应更新吧
#19 楼 @penghong2014
appium 1.6.3
java-client 5.0.0
jdk 8
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2);
@neyo python,appium1.6.3 怎么实现 toast 的?
#25 楼 @oscar
#26 楼 @xiaoan_2131 是 UIAutomator2 的支持,我贴个我写 selendroid testapp 的 demo 好了
#coding=utf-8
from appium import webdriver
import time
import unittest
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions
class ToastTests(unittest.TestCase):
def setUp(self):
desired_caps = {}
desired_caps['automationName'] = 'Uiautomator2'
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '5.1.1'
desired_caps['deviceName'] = 'Android Emulator'
desired_caps['appPackage'] = 'io.selendroid.testapp'
desired_caps['appActivity'] = 'io.selendroid.testapp.HomeScreenActivity'
desired_caps['resetKeyboard'] = 'true'
desired_caps['unicodeKeyboard'] = 'true'
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
def tearDown(self):
self.driver.quit()
def _find_toast(self,message,timeout,poll_frequency,driver):
message = '//*[@text=\'{}\']'.format(message)
element = WebDriverWait(driver,timeout,poll_frequency).until(expected_conditions.presence_of_element_located((By.XPATH,message)))
print element
def test_toast(self):
print self.driver.get_window_size()
self.driver.find_element_by_id('showToastButton').click()
# time.sleep(2)
print self.driver.page_source
self._find_toast('Hello selendroid toast!',10,0.5,self.driver)
time.sleep(10)
self.driver.find_element_by_id('showToastButton').click()
self._find_toast('Hello selendroid toast!',10,0.5,self.driver)
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(ToastTests)
unittest.TextTestRunner(verbosity=2).run(suite)
@neyo 我看你说 selenriod testapp 不知道是啥意思,我就用公司的 app 获取 toast 消息成功,就是通过 automationName 赋值为 Uiautomator2,appium 采用 1.6.3 就可以了。。。多谢帮助!
#28 楼 @xiaoan_2131 不客气,那是我用来写 demo 的 app 啦
@neyo 但我用 Uiautomator view 为什么看不到 toast 消息呢,而通过 Uiautomator2 可以捕获到呢?
@xiaoan_2131 appium1.6.3 好多方法都变了,find_element_by_name 用不了,
@xiaoan_2131 方便加微信么,请教一下
@si509429 关注你的 qq 邮箱
Appium1.6.3 版本是不是不支持 By.name 的方式查找元素了,findElement(By.name)全部失败,大神来确认下
@seveniruby 思寒 你知道删掉 By.name 的原因不,找了好久也没找到原因。By.name 不能用的话,那只能用 xpath 来包@text了或者其他查找方式了
@xiaoan_2131 你 selenium remote server 用的什么版本?我用的 3.0.1 版本,加上 capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2);这行命令后,driver 就初始化失败了。
#28 楼 @xiaoan_2131 你方法中是怎么调用的
@xiaoan_2131 能指教下 python 怎么获取的吗
除了 automationName 赋值为 Uiautomator2,还有其他的设置么,例如 new driver 的时候要 new AndroidUiautomator2Driver ?
appium-Uiautomator2-driver 也已经装了,但是发现还是有问题,方便沟通一下么?
发现不能识别中文的 toast,各位大神有解决办法吗
哈哈,识别中文的办法终于解决,头部加
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
所以 1.6.3 版本以后,toast 的定位方式就和其他元素没什么区别了,另外,使用 UIautomator2 后,driver 就会初始化失败?
python+appium1.6.5 还是搞不定,抓不到 toast,有人指点下吗?
desired_caps['automationName'] = 'uiautomator2'
启动 app 也没问题,appium 没有 error,就是没找到
def test_find_toast(driver,message,timeout,poll_frequency):
message = '//*[@text=\'%s\']' %message
print message
element = WebDriverWait(driver,timeout,poll_frequency).until(expected_conditions.presence_of_element_located((By.XPATH,message)))
print element
def test_find_toast2(driver,message):
try:
driver.find_element_by_xpath('//*[@text=\'%s\']' %message)
print "find toast message %s" %message
except:
print "not find toast message %s" %message
1、安装 appium-uiautomator2-driver: npm install appium-uiautomator2-driver
2、导包
3、设置 automatinName
4、获取 Toast,并通过 print 验证自己获取的内容是否正确
结果:验证通过
环境:
jdk 版本:"1.8.0_131"
appium 版本:1.6.5
selenium:3.3.1
测试设备:Android 5.1
Python:3.5.3
这个是由于你的 toast 内容为中文,由于字符编解码问题导致不能识别,需要在代码顶部写注释如下即可
# coding=utf-8