Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fingerprint endpoint #324

Merged
merged 5 commits into from Apr 15, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -15,4 +15,4 @@ packages
.idea
.vs/
env.json

.vscode/
2 changes: 2 additions & 0 deletions src/Appium.Net/Appium/AppiumCommand.cs
Expand Up @@ -99,6 +99,8 @@ public class AppiumCommand
"/session/{sessionId}/appium/settings"),
new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.TouchID,
"/session/{sessionId}/appium/simulator/touch_id"),
new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.FingerPrint,
"/session/{sessionId}/appium/device/finger_print"),

#endregion Driver Commands

Expand Down
4 changes: 4 additions & 0 deletions src/Appium.Net/Appium/AppiumCommandExecutionHelper.cs
Expand Up @@ -127,6 +127,10 @@ public static string GetClipboardText(IExecuteMethod executeMethod)
executeMethod.Execute(AppiumDriverCommand.PushFile, new Dictionary<string, object>()
{ ["path"] = pathOnDevice, ["data"] = base64Data });

public static void FingerPrint(IExecuteMethod executeMethod, int fingerprintId) =>
executeMethod.Execute(AppiumDriverCommand.FingerPrint, new Dictionary<string, object>()
{ ["fingerprintId"] = fingerprintId});

public static void PushFile(IExecuteMethod executeMethod, string pathOnDevice, FileInfo file)
{
if (file == null)
Expand Down
5 changes: 4 additions & 1 deletion src/Appium.Net/Appium/AppiumDriver.cs
Expand Up @@ -254,6 +254,9 @@ public void Rotate(Dictionary<string, int> opts)

public void ResetApp() => ((IExecuteMethod) this).Execute(AppiumDriverCommand.ResetApp);

public void FingerPrint(int fingerprintId) =>
AppiumCommandExecutionHelper.FingerPrint(this, fingerprintId);

public void BackgroundApp() =>
Execute(AppiumDriverCommand.BackgroundApp,
AppiumCommandExecutionHelper.PrepareArgument("seconds", AppiumCommandExecutionHelper.PrepareArgument("timeout", null)));
Expand Down Expand Up @@ -305,7 +308,7 @@ public Location Location
Execute(AppiumDriverCommand.SetLocation, location.ToDictionary());
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not needed

#endregion MJsonMethod Members

#region Context
Expand Down
5 changes: 5 additions & 0 deletions src/Appium.Net/Appium/AppiumDriverCommand.cs
Expand Up @@ -275,6 +275,11 @@ public class AppiumDriverCommand
/// </summary>
public const string TouchID = "touchId";

/// <summary>
/// Represents the fingerPrint command
public const string FingerPrint = "fingerPrint";
/// </summary>

public const string ReplaceValue = "replaceValue";

public const string SetValue = "setValue";
Expand Down
48 changes: 48 additions & 0 deletions test/integration/Android/FingerprintTest.cs
@@ -0,0 +1,48 @@
using System;
using System.Text.RegularExpressions;
using Appium.Net.Integration.Tests.helpers;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Appium.Android;
using OpenQA.Selenium.Appium.Enums;

namespace Appium.Net.Integration.Tests.Android
{
[TestFixture(Category = "Device")]
public class FingerprintTest
{
private AndroidDriver<IWebElement> _driver;
private const string ClipboardTestString = "Hello Clipboard";
private const string Base64RegexPattern = @"^[a-zA-Z0-9\+/]*={0,2}$";

[OneTimeSetUp]
public void BeforeAll()
{
var capabilities = Env.ServerIsRemote()
? Caps.GetAndroidCaps(Apps.Get("androidApiDemos"))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the condition here has no effect, since both branches are equal

: Caps.GetAndroidCaps(Apps.Get("androidApiDemos"));
capabilities.AddAdditionalCapability(MobileCapabilityType.FullReset, true);
var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri;
_driver = new AndroidDriver<IWebElement>(serverUri, capabilities, Env.InitTimeoutSec);
_driver.Manage().Timeouts().ImplicitWait = Env.ImplicitTimeoutSec;
}

[SetUp]
public void SetUp()
{
_driver?.LaunchApp();
}

[TearDown]
public void TearDown()
{
_driver?.CloseApp();
}

[Test]
public void TestSendFingerprint()
{
_driver.FingerPrint(1);
dpgraham marked this conversation as resolved.
Show resolved Hide resolved
}
}
}