摘要
GetAttribute 实际上从字面上我们就能够明白,它是获取元素的一些属性。类似于文本内容,类名,resourId等。当然还包括了一些属性状态,如clickable,checkable等等,
正文
GetAttribute的代码其实挺简单的 我们来看下吧
public AndroidCommandResult execute(final AndroidCommand command)
throws JSONException {
if (command.isElementCommand()) {
// only makes sense on an element
final Hashtable<String, Object> params = command.params();
try {
final AndroidElement el = command.getElement();
final String attr = params.get("attribute").toString();
if (attr.equals("name") || attr.equals("text")
|| attr.equals("className") || attr.equals("resourceId")) {
return getSuccessResult(el.getStringAttribute