Skip to content

Commit 2d22489

Browse files
mohitc1CopilotCopilot
authored
Add handleButtonClickForObjectWithTextSafely overload to fix build, Fixes AB#3586240 (#3097)
As seen here https://identitydivision.visualstudio.com/Engineering/ISP%20-%20ID%20Risk%20for%20Passkey%20Registration%20and%20Recovery/_build/results?buildId=1626465&view=logs&s=ff4555a9-e895-5c04-ab14-88c3aa79b4da&j=9a146641-6417-5767-ad44-2e332adab356 Seems to have happened after AzureAD/microsoft-authentication-library-for-android#2502 /mnt/vss/_work/1/s/msalautomationapp/src/androidTest/java/com/microsoft/identity/client/msal/automationapp/testpass/broker/foci/TestCase833544.java:107: error: method handleButtonClickForObjectWithTextSafely in class UiAutomatorUtils cannot be applied to given types; UiAutomatorUtils.handleButtonClickForObjectWithTextSafely("Close", CommonUtils.FIND_UI_ELEMENT_TIMEOUT_SHORT); Fixes [AB#3586240](https://identitydivision.visualstudio.com/fac9d424-53d2-45c0-91b5-ef6ba7a6bf26/_workitems/edit/3586240) --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: mohitc1 <22034758+mohitc1@users.noreply.github.com>
1 parent 2751979 commit 2d22489

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

  • uiautomationutilities/src/main/java/com/microsoft/identity/client/ui/automation/utils

uiautomationutilities/src/main/java/com/microsoft/identity/client/ui/automation/utils/UiAutomatorUtils.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,28 @@ public static void handleButtonClickForObjectWithTextSafely(@NonNull final Strin
550550
}
551551
}
552552

553+
554+
/**
555+
* Clicks the button element that contains the supplied text.
556+
* Do not throw an exception if the button is not found. Waits
557+
* for the button to exist with the supplied timeout before giving up
558+
* and logging a warning.
559+
*
560+
* @param text the text on the button to click
561+
* @param existsTimeout the maximum time to wait, in milliseconds, for the button
562+
* to exist before giving up and logging a warning
563+
*/
564+
public static void handleButtonClickForObjectWithTextSafely(@NonNull final String text, final long existsTimeout) {
565+
final UiObject button = obtainUiObjectWithText(text, existsTimeout);
566+
567+
try {
568+
button.click();
569+
} catch (final UiObjectNotFoundException e) {
570+
Logger.w(TAG, "Button with text \"" + text + "\" was not found after waiting "
571+
+ existsTimeout + " ms: " + e.getMessage());
572+
}
573+
}
574+
553575
/**
554576
* Clicks the button element that contains text matching the supplied regex
555577
*/

0 commit comments

Comments
 (0)