generated from jfversluis/Plugin.Maui.Feature
-
-
Notifications
You must be signed in to change notification settings - Fork 10
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 #13 from pictos/pj/update-code-to-match-21305
Update files to match .NET MAUI implementation
- Loading branch information
Showing
10 changed files
with
859 additions
and
21 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
src/Plugin.Maui.UITestHelpers.Appium/Actions/AppiumCatalystMouseActions.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,63 @@ | ||
using OpenQA.Selenium.Appium; | ||
using Plugin.Maui.UITestHelpers.Core; | ||
|
||
namespace Plugin.Maui.UITestHelpers.Appium | ||
{ | ||
public class AppiumCatalystMouseActions : ICommandExecutionGroup | ||
{ | ||
const string DoubleClickCommand = "doubleClick"; | ||
|
||
readonly List<string> _commands = new() | ||
{ | ||
DoubleClickCommand, | ||
}; | ||
readonly AppiumApp _appiumApp; | ||
|
||
public AppiumCatalystMouseActions(AppiumApp appiumApp) | ||
{ | ||
_appiumApp = appiumApp; | ||
} | ||
|
||
public bool IsCommandSupported(string commandName) | ||
{ | ||
return _commands.Contains(commandName, StringComparer.OrdinalIgnoreCase); | ||
} | ||
|
||
public CommandResponse Execute(string commandName, IDictionary<string, object> parameters) | ||
{ | ||
return commandName switch | ||
{ | ||
DoubleClickCommand => DoubleClick(parameters), | ||
_ => CommandResponse.FailedEmptyResponse, | ||
}; | ||
} | ||
|
||
CommandResponse DoubleClick(IDictionary<string, object> parameters) | ||
{ | ||
var element = GetAppiumElement(parameters["element"]); | ||
|
||
if (element != null) | ||
{ | ||
_appiumApp.Driver.ExecuteScript("macos: doubleClick", new Dictionary<string, object> | ||
{ | ||
{ "elementId", element.Id }, | ||
}); | ||
} | ||
return CommandResponse.SuccessEmptyResponse; | ||
} | ||
|
||
static AppiumElement? GetAppiumElement(object element) | ||
{ | ||
if (element is AppiumElement appiumElement) | ||
{ | ||
return appiumElement; | ||
} | ||
else if (element is AppiumDriverElement driverElement) | ||
{ | ||
return driverElement.AppiumElement; | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
} |
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
65 changes: 65 additions & 0 deletions
65
src/Plugin.Maui.UITestHelpers.Appium/Actions/AppiumIOSMouseActions.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,65 @@ | ||
using OpenQA.Selenium.Appium; | ||
using Plugin.Maui.UITestHelpers.Core; | ||
|
||
|
||
namespace Plugin.Maui.UITestHelpers.Appium | ||
{ | ||
public class AppiumIOSMouseActions : ICommandExecutionGroup | ||
{ | ||
const string DoubleClickCommand = "doubleClick"; | ||
|
||
readonly List<string> _commands = new() | ||
{ | ||
DoubleClickCommand, | ||
}; | ||
readonly AppiumApp _appiumApp; | ||
|
||
public AppiumIOSMouseActions(AppiumApp appiumApp) | ||
{ | ||
_appiumApp = appiumApp; | ||
} | ||
|
||
public bool IsCommandSupported(string commandName) | ||
{ | ||
return _commands.Contains(commandName, StringComparer.OrdinalIgnoreCase); | ||
} | ||
|
||
public CommandResponse Execute(string commandName, IDictionary<string, object> parameters) | ||
{ | ||
return commandName switch | ||
{ | ||
DoubleClickCommand => DoubleClick(parameters), | ||
_ => CommandResponse.FailedEmptyResponse, | ||
}; | ||
} | ||
|
||
CommandResponse DoubleClick(IDictionary<string, object> parameters) | ||
{ | ||
var element = GetAppiumElement(parameters["element"]); | ||
|
||
if (element != null) | ||
{ | ||
_appiumApp.Driver.ExecuteScript("mobile: doubleTap", new Dictionary<string, object> | ||
{ | ||
{ "elementId", element.Id }, | ||
}); | ||
} | ||
|
||
return CommandResponse.SuccessEmptyResponse; | ||
} | ||
|
||
static AppiumElement? GetAppiumElement(object element) | ||
{ | ||
if (element is AppiumElement appiumElement) | ||
{ | ||
return appiumElement; | ||
} | ||
else if (element is AppiumDriverElement driverElement) | ||
{ | ||
return driverElement.AppiumElement; | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.