答案 0 :(得分:3)
如果您不能对EditText字段断言错误消息,请尝试此方法。
将图像转换为文本文件
def assettoast(string)
sname = (0...8).map { (65 + rand(26)).chr }.join
$driver.driver.save_screenshot("#{sname}")
#Make sure tesseract is installed in the system. If not you can install using "brew install tesseract" in mac
system ("tesseract #{sname} #{sname}")
text_file="#{sname}.txt"
var= get_string_from_file(string, text_file)
raise if var != true
end
检查文本文件中是否存在错误消息
def get_string_from_file(word, filename)
File.readlines(filename).each do |line|
return true if line.include?(word)
end
end
答案 1 :(得分:0)
没有人会使用uiautomatorviewer和Google的原始UiAutomator。检查旧的thread
但是您可以尝试Appium自己的实现UiAutomator2和Appium desktop inspector,它可能会解析错误。
否则,会有新的appium端点来比较图像:
/session/:sessionId/appium/compare_images
您可以使用它来验证屏幕上的错误