Appium Android UI测试-如何验证元素的样式属性? [英] Appium Android UI testing - how to verify the style attribute of an element?
问题描述
我想验证元素的样式,即textview中显示的文本的颜色.不论是黑色还是蓝色. textColor或textSize.该信息未在uiautomatorviewer中列出.
I would like to verify the style of an element i.e. the color of the text shown in a textview. Whether it is black or blue ex. textColor or textSize. This information is not listed in the uiautomatorviewer.
我可以使用elem.get_attribute("text")获得文本,因为在节点详细信息"中可以看到文本值.有没有一种方法可以检查样式属性?(我可以使用纯硒来轻松做到这一点.)
I can get the text using elem.get_attribute("text") as the text value is seen in the Node Detail. Is there a way to check for the style attributes?( I can do this fairly easy with straight selenium.)
推荐答案
更新.事实证明,使用appium webdriver无法做到这一点.
Update. As it turns out that cannot be done with appium webdriver.
对于那些想知道这是我来自appium支持小组的答案的人:
For those of you who are wondering this is the answer I rec'd from the appium support group:
appium无法做到这一点,因为底层的UIAutomator框架不允许我们这样做. 在应用程序的本机上下文中,这无法完成
This cannot be done by appium as underlying UIAutomator framework does not allow us to do so. In app's native context this cannot be done
在应用程序的webview上下文中,此操作与以下内容相同,因为webview只是应用程序内部的无镶边浏览器会话 打印searchBtn.value_of_css_property("background-color").
In app's webview's context this will be same as below because webview is nothing but a chromeless browser session inside and app print searchBtn.value_of_css_property("background-color").
摘要 用于NATIVE CONTEXT内的元素== >>否 用于WEBVIEW CONTEXT中的元素== >>是
Summary for element inside NATIVE CONTEXT ==>> NO for element inside WEBVIEW CONTEXT ==>> YES
希望这会有所帮助.
这篇关于Appium Android UI测试-如何验证元素的样式属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!