server/src/main/java/com/amplify/honeydew_server/actions/SelectMenuInSettings.java in honeydew-0.14.0 vs server/src/main/java/com/amplify/honeydew_server/actions/SelectMenuInSettings.java in honeydew-0.15.0

- old
+ new

@@ -1,7 +1,8 @@ package com.amplify.honeydew_server.actions; +import android.widget.TextView; import com.android.uiautomator.core.*; import com.amplify.honeydew_server.Action; import com.amplify.honeydew_server.Result; import java.util.Map; @@ -12,11 +13,21 @@ } @Override public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException { String menuName = (String) arguments.get("menuName"); - UiScrollable settingsMenu = new UiScrollable(new UiSelector().scrollable(true).focused(true)); - (settingsMenu.getChildByText(new UiSelector().className(android.widget.TextView.class.getName()),menuName)).click(); - return Result.OK; + final UiScrollable settingsMenu = new UiScrollable(new UiSelector().scrollable(true).focused(true)); + if(!isUiObjectAvailable(settingsMenu,arguments)){ + return Result.FAILURE; + } + + final UiSelector childPattern = new UiSelector().className(TextView.class.getName()); + final UiObject childByText = settingsMenu.getChildByText(childPattern, menuName); + if (isUiObjectAvailable(childByText, arguments)) { + childByText.click(); + return Result.OK; + } + + return Result.FAILURE; } }