Skip to content

Commit

Permalink
[Testing] Implement PressEnter Appium action in Catalyst (#25854)
Browse files Browse the repository at this point in the history
* Implement PressEnter Appium action in Catalyst

* Fix merge error
  • Loading branch information
jsuarezruiz authored Nov 26, 2024
1 parent 72af857 commit d160357
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using OpenQA.Selenium;
using OpenQA.Selenium.Appium.Windows;
using OpenQA.Selenium.Interactions;
using UITest.Core;

namespace UITest.Appium
{
public class AppiumCatalystVirtualKeyboardActions : AppiumVirtualKeyboardActions
{
readonly AppiumApp _appiumApp;

public AppiumCatalystVirtualKeyboardActions(AppiumApp appiumApp)
: base(appiumApp)
{
_appiumApp = appiumApp;
}

protected override CommandResponse PressEnter(IDictionary<string, object> parameters)
{
try
{
// https://developer.apple.com/documentation/xctest/xcuikeyboardkey?language=objc
string[] keys = ["XCUIKeyboardKeyEnter"]; // Enter Key

_appiumApp.Driver.ExecuteScript("macos: keys", new Dictionary<string, object>
{
{ "keys", keys },
});
}
catch (InvalidElementStateException)
{
return CommandResponse.FailedEmptyResponse;
}

return CommandResponse.SuccessEmptyResponse;
}
}
}
3 changes: 2 additions & 1 deletion src/TestUtils/src/UITest.Appium/AppiumCatalystApp.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Enums;
using OpenQA.Selenium.Appium.Mac;
using UITest.Core;
Expand All @@ -13,6 +13,7 @@ public AppiumCatalystApp(Uri remoteAddress, IConfig config)
_commandExecutor.AddCommandGroup(new AppiumCatalystMouseActions(this));
_commandExecutor.AddCommandGroup(new AppiumCatalystTouchActions(this));
_commandExecutor.AddCommandGroup(new AppiumCatalystAlertActions(this));
_commandExecutor.AddCommandGroup(new AppiumCatalystVirtualKeyboardActions(this));
}

public override ApplicationState AppState
Expand Down

0 comments on commit d160357

Please sign in to comment.