diff --git a/src/main/java/io/appium/java_client/ios/IOSMobileCommandHelper.java b/src/main/java/io/appium/java_client/ios/IOSMobileCommandHelper.java index d99842d33..1a63c3a40 100644 --- a/src/main/java/io/appium/java_client/ios/IOSMobileCommandHelper.java +++ b/src/main/java/io/appium/java_client/ios/IOSMobileCommandHelper.java @@ -51,10 +51,23 @@ public class IOSMobileCommandHelper extends MobileCommand { /** * This method forms a {@link java.util.Map} of parameters for the toggling touchId * enrollment in simulator. - * + * The method is deprecated. Please use {@link #toggleTouchIdEnrollmentCommand(boolean)} instead. */ + @Deprecated public static Map.Entry> toggleTouchIdEnrollmentCommand() { return new AbstractMap.SimpleEntry<>( TOUCH_ID_ENROLLMENT, ImmutableMap.of()); } + + /** + * This method forms a {@link java.util.Map} of parameters for the toggling touchId + * enrollment in simulator. + * + * @param enabled Whether to enable or disable Touch ID Enrollment for Simulator. + * + */ + public static Map.Entry> toggleTouchIdEnrollmentCommand(boolean enabled) { + return new AbstractMap.SimpleEntry<>( + TOUCH_ID_ENROLLMENT, prepareArguments("enabled", enabled)); + } } diff --git a/src/main/java/io/appium/java_client/ios/PerformsTouchID.java b/src/main/java/io/appium/java_client/ios/PerformsTouchID.java index 53a3d1bf1..e1405c22a 100644 --- a/src/main/java/io/appium/java_client/ios/PerformsTouchID.java +++ b/src/main/java/io/appium/java_client/ios/PerformsTouchID.java @@ -35,9 +35,24 @@ default void performTouchID(boolean match) { /** * Enrolls touchId in iOS Simulators. - * + * This method is deprecated. Please use {@link #toggleTouchIDEnrollment(boolean)} instead */ + @Deprecated default void toggleTouchIDEnrollment() { CommandExecutionHelper.execute(this, toggleTouchIdEnrollmentCommand()); } + + /** + * Enrolls touchId in iOS Simulators. This call will only work if Appium process or its + * parent application (e.g. Terminal.app or Appium.app) has + * access to Mac OS accessibility in System Preferences > + * Security & Privacy > Privacy > Accessibility list. + * + * @param enabled Whether to enable or disable Touch ID Enrollment. The actual state of the feature + * will only be changed if the current value is different from the previous one. + * Multiple calls of the method with the same argument value have no effect. + */ + default void toggleTouchIDEnrollment(boolean enabled) { + CommandExecutionHelper.execute(this, toggleTouchIdEnrollmentCommand(enabled)); + } } diff --git a/src/test/java/io/appium/java_client/ios/XCUIAutomationTest.java b/src/test/java/io/appium/java_client/ios/XCUIAutomationTest.java index f4b2c99e0..907a3a746 100644 --- a/src/test/java/io/appium/java_client/ios/XCUIAutomationTest.java +++ b/src/test/java/io/appium/java_client/ios/XCUIAutomationTest.java @@ -50,7 +50,7 @@ public class XCUIAutomationTest extends AppXCUITTest { @Test public void testTouchId() { try { - driver.toggleTouchIDEnrollment(); + driver.toggleTouchIDEnrollment(true); driver.performTouchID(true); driver.performTouchID(false); assertEquals(true, true);