diff --git a/src/main/java/io/appium/java_client/MobileCommand.java b/src/main/java/io/appium/java_client/MobileCommand.java index 85ea4f4ff..542c69884 100644 --- a/src/main/java/io/appium/java_client/MobileCommand.java +++ b/src/main/java/io/appium/java_client/MobileCommand.java @@ -57,6 +57,7 @@ public class MobileCommand { //iOS protected static final String SHAKE; protected static final String TOUCH_ID; + protected static final String TOUCH_ID_ENROLLMENT; //Android protected static final String CURRENT_ACTIVITY; protected static final String END_TEST_COVERAGE; @@ -103,6 +104,7 @@ public class MobileCommand { LOCK = "lock"; SHAKE = "shake"; TOUCH_ID = "touchId"; + TOUCH_ID_ENROLLMENT = "toggleEnrollTouchId"; CURRENT_ACTIVITY = "currentActivity"; END_TEST_COVERAGE = "endTestCoverage"; @@ -151,6 +153,8 @@ public class MobileCommand { //iOS commandRepository.put(SHAKE, postC("/session/:sessionId/appium/device/shake")); commandRepository.put(TOUCH_ID, postC("/session/:sessionId/appium/simulator/touch_id")); + commandRepository.put(TOUCH_ID_ENROLLMENT, + postC("/session/:sessionId/appium/simulator/toggle_touch_id_enrollment")); //Android commandRepository.put(CURRENT_ACTIVITY, getC("/session/:sessionId/appium/device/current_activity")); 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 74a0a6f52..01c9f6566 100644 --- a/src/main/java/io/appium/java_client/ios/IOSMobileCommandHelper.java +++ b/src/main/java/io/appium/java_client/ios/IOSMobileCommandHelper.java @@ -77,4 +77,14 @@ public class IOSMobileCommandHelper extends MobileCommand { return new AbstractMap.SimpleEntry<>( TOUCH_ID, prepareArguments("match", match)); } + + /** + * This method forms a {@link java.util.Map} of parameters for the toggling touchId + * enrollment in simulator. + * + */ + public static Map.Entry> toggleTouchIdEnrollmentCommand() { + return new AbstractMap.SimpleEntry<>( + TOUCH_ID_ENROLLMENT, ImmutableMap.of()); + } } 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 8f5555347..5b0b422f2 100644 --- a/src/main/java/io/appium/java_client/ios/PerformsTouchID.java +++ b/src/main/java/io/appium/java_client/ios/PerformsTouchID.java @@ -17,6 +17,7 @@ package io.appium.java_client.ios; import static io.appium.java_client.ios.IOSMobileCommandHelper.touchIdCommand; +import static io.appium.java_client.ios.IOSMobileCommandHelper.toggleTouchIdEnrollmentCommand; import io.appium.java_client.CommandExecutionHelper; import io.appium.java_client.ExecutesMethod; @@ -31,4 +32,12 @@ public interface PerformsTouchID extends ExecutesMethod { default void performTouchID(boolean match) { CommandExecutionHelper.execute(this, touchIdCommand(match)); } + + /** + * Enrolls touchId in iOS Simulators. + * + */ + default void toggleTouchIDEnrollment() { + CommandExecutionHelper.execute(this, toggleTouchIdEnrollmentCommand()); + } } diff --git a/src/test/java/io/appium/java_client/ios/AppXCUITTest.java b/src/test/java/io/appium/java_client/ios/AppXCUITTest.java index 8eda617d5..efbb81210 100644 --- a/src/test/java/io/appium/java_client/ios/AppXCUITTest.java +++ b/src/test/java/io/appium/java_client/ios/AppXCUITTest.java @@ -29,6 +29,7 @@ public class AppXCUITTest extends BaseIOSTest { capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, ""); capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "10.1"); capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 6"); + capabilities.setCapability(IOSMobileCapabilityType.ALLOW_TOUCHID_ENROLL, "true"); //sometimes environment has performance problems capabilities.setCapability(IOSMobileCapabilityType.LAUNCH_TIMEOUT, 500000); capabilities 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 36154b45b..b463ee80a 100644 --- a/src/test/java/io/appium/java_client/ios/XCUIAutomationTest.java +++ b/src/test/java/io/appium/java_client/ios/XCUIAutomationTest.java @@ -48,6 +48,7 @@ public class XCUIAutomationTest extends AppXCUITTest { @Test public void testTouchId() { try { + driver.toggleTouchIDEnrollment(); driver.performTouchID(true); driver.performTouchID(false); assertEquals(true, true);