forked from 2gis/Winium.Mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request 2gis#160 from 2gis/clear-command
Add clear command Fix driver crashing on empty request
- Loading branch information
Showing
22 changed files
with
158 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
Winium/Winium.StoreApps.InnerServer/Commands/ClearCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
namespace Winium.StoreApps.InnerServer.Commands | ||
{ | ||
#region | ||
|
||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Automation.Peers; | ||
using Windows.UI.Xaml.Automation.Provider; | ||
using Windows.UI.Xaml.Controls; | ||
|
||
using Winium.StoreApps.Common; | ||
using Winium.StoreApps.Common.Exceptions; | ||
using Winium.StoreApps.InnerServer.Commands.Helpers; | ||
|
||
#endregion | ||
|
||
internal class ClearCommand : CommandBase | ||
{ | ||
#region Public Properties | ||
|
||
public string ElementId { get; set; } | ||
|
||
#endregion | ||
|
||
#region Public Methods and Operators | ||
|
||
protected override string DoImpl() | ||
{ | ||
var element = this.Automator.ElementsRegistry.GetRegisteredElement(this.ElementId); | ||
var control = element.Element as Control; | ||
if (control == null) | ||
{ | ||
throw new AutomationException("Element referenced is not of control type.", ResponseStatus.UnknownError); | ||
} | ||
|
||
control.TrySetText(string.Empty); | ||
return this.JsonResponse(); | ||
} | ||
|
||
#endregion | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
Winium/Winium.StoreApps.InnerServer/Commands/Helpers/ControlExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
namespace Winium.StoreApps.InnerServer.Commands.Helpers | ||
{ | ||
#region | ||
|
||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Automation.Peers; | ||
using Windows.UI.Xaml.Automation.Provider; | ||
using Windows.UI.Xaml.Controls; | ||
|
||
using Winium.StoreApps.Common; | ||
using Winium.StoreApps.Common.Exceptions; | ||
|
||
#endregion | ||
|
||
internal static class ContorlExtensions | ||
{ | ||
internal static void TrySetText(this Control element, string text) | ||
{ | ||
// TODO Research why TextBox does not support IValueProvider | ||
var provider = element.GetProviderOrDefault<IValueProvider>(PatternInterface.Value); | ||
|
||
if (provider != null) | ||
{ | ||
provider.SetValue(text); | ||
} | ||
else if (element is TextBox) | ||
{ | ||
var textBox = element as TextBox; | ||
textBox.Text = text; | ||
textBox.SelectionStart = text.Length; | ||
} | ||
else if (element is PasswordBox) | ||
{ | ||
var passwordBox = element as PasswordBox; | ||
passwordBox.Password = text; | ||
} | ||
else | ||
{ | ||
throw new AutomationException("Element does not support SendKeys.", ResponseStatus.UnknownError); | ||
} | ||
|
||
// TODO: new parameter - FocusState | ||
element.Focus(FocusState.Pointer); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters