Skip to content

Commit

Permalink
Revert changes for AppiumDriver
Browse files Browse the repository at this point in the history
Make Lock methods specfic for iOS and Android
  • Loading branch information
Dor-bl committed Dec 7, 2024
1 parent 6e99be0 commit fbd47a2
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 30 deletions.
26 changes: 26 additions & 0 deletions src/Appium.Net/Appium/Android/AndroidDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,32 @@ public IList<string> GetPerformanceDataTypes() =>

#region Device Interactions

/// <summary>
/// Locks the device. Optionally, unlocks it after a specified number of seconds.
/// </summary>
/// <param name="seconds">
/// The number of seconds after which the device will be automatically unlocked.
/// Set to 0 or leave it empty to require manual unlock.
/// </param>
/// <exception cref="WebDriverException">Thrown if the command execution fails.</exception>
public void Lock(int? seconds = null)
{
var parameters = new Dictionary<string, object>();

if (seconds.HasValue && seconds.Value > 0)
{
parameters["seconds"] = seconds.Value;
}

ExecuteScript("mobile: lock", parameters);
}

/// <summary>
/// Check if the device is locked
/// </summary>
/// <returns>true if device is locked, false otherwise</returns>
public bool IsLocked() => (bool)ExecuteScript("mobile: isLocked");

/// <summary>
/// Unlocks the device if it is locked. No operation if the device's screen is not locked.
/// </summary>
Expand Down
30 changes: 0 additions & 30 deletions src/Appium.Net/Appium/AppiumDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -586,35 +586,5 @@ internal static ReadOnlyCollection<T> ConvertToExtendedWebElementCollection<T>(I
}

#endregion

#region Device Interactions

/// <summary>
/// Locks the device. Optionally, unlocks it after a specified number of seconds.
/// </summary>
/// <param name="seconds">
/// The number of seconds after which the device will be automatically unlocked.
/// Set to 0 or leave it empty to require manual unlock.
/// </param>
/// <exception cref="WebDriverException">Thrown if the command execution fails.</exception>
public void Lock(int? seconds = null)
{
var parameters = new Dictionary<string, object>();

if (seconds.HasValue && seconds.Value > 0)
{
parameters["seconds"] = seconds.Value;
}

ExecuteScript("mobile: lock", parameters);
}

/// <summary>
/// Check if the device is locked
/// </summary>
/// <returns>true if device is locked, false otherwise</returns>
public bool IsLocked() => (bool)ExecuteScript("mobile: isLocked");

#endregion
}
}
26 changes: 26 additions & 0 deletions src/Appium.Net/Appium/iOS/IOSDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,32 @@ public void HideKeyboard(string key, string strategy = null) =>

public void PerformTouchID(bool match) => IOSCommandExecutionHelper.PerformTouchID(this, match);

/// <summary>
/// Check if the device is locked
/// </summary>
/// <returns>true if device is locked, false otherwise</returns>
public bool IsLocked() => (bool)ExecuteScript("mobile: isLocked");

/// <summary>
/// Locks the device. Optionally, unlocks it after a specified number of seconds.
/// </summary>
/// <param name="seconds">
/// The number of seconds after which the device will be automatically unlocked.
/// Set to 0 or leave it empty to require manual unlock.
/// </param>
/// <exception cref="WebDriverException">Thrown if the command execution fails.</exception>
public void Lock(int? seconds = null)
{
var parameters = new Dictionary<string, object>();

if (seconds.HasValue && seconds.Value > 0)
{
parameters["seconds"] = seconds.Value;
}

ExecuteScript("mobile: lock", parameters);
}

public void Unlock() => ExecuteScript("mobile: unlock");

/// <summary>
Expand Down

0 comments on commit fbd47a2

Please sign in to comment.