Skip to content

Commit

Permalink
fix first visible view logic, and gradle build logic (appium#113)
Browse files Browse the repository at this point in the history
* use local gradle wrapper rather than relying on system gradle and hoping it's compatible

* FirstVisibleView should find the first child view, not the first grandchild view
  • Loading branch information
jlipps authored and imurchie committed Jan 22, 2018
1 parent f0a9588 commit 0dd44af
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,26 @@ public AppiumResponse safeHandle(IHttpRequest request) {
KnownElements ke = new KnownElements();
Object firstObject = null;
if (element.getUiObject() instanceof UiObject) {
Logger.debug("Container for first visible is a uiobject");
UiObject childObject = ((UiObject) element.getUiObject()).getChild(new UiSelector().index(0));
for (int i = 0; i < childObject.getChildCount(); i++) {
UiObject object = childObject.getChild(new UiSelector().index(i));
UiObject uiObject = (UiObject) element.getUiObject();
Logger.debug("Container for first visible is a uiobject; looping through children");
for (int i = 0; i < uiObject.getChildCount(); i++) {
UiObject object = uiObject.getChild(new UiSelector().index(i));
if (object.exists()) {
firstObject = object;
break;
}
}
} else {
Logger.debug("Container for first visible is a uiobject2");
List<UiObject2> childObjects = ((UiObject2) element.getUiObject()).getChildren();
UiObject2 uiObject = (UiObject2) element.getUiObject();
Logger.debug("Container for first visible is a uiobject2; looping through children");
List<UiObject2> childObjects = uiObject.getChildren();
if (childObjects.isEmpty()) {
throw new UiObjectNotFoundException("Could not get children for container object");
}
UiObject2 childObject = childObjects.get(0);
for (int i = 0; i < childObject.getChildCount(); i++) {
UiObject2 object2 = childObject.getChildren().get(i);
for (UiObject2 childObject : childObjects) {
try {
if (AccessibilityNodeInfoGetter.fromUiObject(object2) != null) {
firstObject = object2;
if (AccessibilityNodeInfoGetter.fromUiObject(childObject) != null) {
firstObject = childObject;
break;
}
} catch (UiAutomator2Exception ignored) {
Expand Down
Empty file modified gradlew
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"homepage": "https://github.com/appium/appium-uiautomator2-server",
"scripts": {
"bump-gradle-version": "node update-gradle-version.js --package-version=${npm_package_version} && git add app/build.gradle",
"build": "gradle clean assembleServerDebug assembleServerDebugAndroidTest",
"build": "./gradlew clean assembleServerDebug assembleServerDebugAndroidTest",
"move-server": "cp app/build/outputs/apk/server/debug/appium-uiautomator2-server-v${npm_package_version}.apk ./apks",
"move-test": "cp app/build/outputs/apk/androidTest/server/debug/appium-uiautomator2-server-debug-androidTest.apk ./apks",
"move-apks": "rm -rf apks && mkdir -p apks && npm run move-server && npm run move-test",
Expand Down

0 comments on commit 0dd44af

Please sign in to comment.