Skip to content

Commit

Permalink
Add 'password' attribute to attributes list (#51)
Browse files Browse the repository at this point in the history
* Add 'password attribute to attributes list'

* Tune formatting
  • Loading branch information
Mykola Mokhnach authored Nov 14, 2017
1 parent 0f89532 commit 6d87ed8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 26 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ bootstrap/.classpath
bootstrap/target/
node_modules
*.log
*.iml
57 changes: 31 additions & 26 deletions bootstrap/src/io/appium/android/bootstrap/AndroidElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,31 +93,35 @@ public Point getAbsolutePosition(final Point point)

public boolean getBoolAttribute(final String attr)
throws UiObjectNotFoundException, NoAttributeFoundException {
boolean res;
if (attr.equals("enabled")) {
res = el.isEnabled();
} else if (attr.equals("checkable")) {
res = el.isCheckable();
} else if (attr.equals("checked")) {
res = el.isChecked();
} else if (attr.equals("clickable")) {
res = el.isClickable();
} else if (attr.equals("focusable")) {
res = el.isFocusable();
} else if (attr.equals("focused")) {
res = el.isFocused();
} else if (attr.equals("longClickable")) {
res = el.isLongClickable();
} else if (attr.equals("scrollable")) {
res = el.isScrollable();
} else if (attr.equals("selected")) {
res = el.isSelected();
} else if (attr.equals("displayed")) {
res = el.exists();
} else {
throw new NoAttributeFoundException(attr);
switch (attr) {
case "enabled":
return el.isEnabled();
case "checkable":
return el.isCheckable();
case "checked":
return el.isChecked();
case "clickable":
return el.isClickable();
case "focusable":
return el.isFocusable();
case "focused":
return el.isFocused();
case "longClickable":
return el.isLongClickable();
case "scrollable":
return el.isScrollable();
case "selected":
return el.isSelected();
case "displayed":
return el.exists();
case "password":
AccessibilityNodeInfo node = (AccessibilityNodeInfo) invoke(
method(el.getClass(), "findAccessibilityNodeInfo", long.class),
el, Configurator.getInstance().getWaitForSelectorTimeout());
return node.isPassword();
default:
throw new NoAttributeFoundException(attr);
}
return res;
}

public Rect getBounds() throws UiObjectNotFoundException {
Expand Down Expand Up @@ -151,12 +155,13 @@ public String getResourceId() throws UiObjectNotFoundException {
* Unfortunately UiObject does not implement a getResourceId method.
* There is currently no way to determine the resource-id of a given
* element represented by UiObject. Until this support is added to
* UiAutomater, we try to match the implementation pattern that is
* UiAutomator, we try to match the implementation pattern that is
* already used by UiObject for getting attributes using reflection.
* The returned string matches exactly what is displayed in the
* UiAutomater inspector.
*/
AccessibilityNodeInfo node = (AccessibilityNodeInfo) invoke( method(el.getClass(), "findAccessibilityNodeInfo", long.class),
AccessibilityNodeInfo node = (AccessibilityNodeInfo) invoke(
method(el.getClass(), "findAccessibilityNodeInfo", long.class),
el, Configurator.getInstance().getWaitForSelectorTimeout());

if (node == null) {
Expand Down

0 comments on commit 6d87ed8

Please sign in to comment.