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 UWP app support #15

Merged
merged 2 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ FlaUI.WebDriver is a [W3C WebDriver2](https://www.w3.org/TR/webdriver2/) impleme

The following capabilities are supported:

| Capability Name | Description | Example value |
| ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- |
| platformName | Must be set to `windows` (case-insensitive). | `windows` |
| appium:app | The path to the application. It is also possible to set app to `Root`. In such case the session will be invoked without any explicit target application. Either this capability, `appTopLevelWindow` or `appTopLevelWindowTitleMatch` must be provided on session startup. | `C:\Windows\System32\notepad.exe` |
| appium:appArguments | Application arguments string, for example `/?`. |
| appium:appTopLevelWindow | The hexadecimal handle of an existing application top level window to attach to, for example `0x12345` (should be of string type). Either this capability, `appTopLevelWindowTitleMatch` or `app` must be provided on session startup. | `0xC0B46` |
| appium:appTopLevelWindowTitleMatch | The title of an existing application top level window to attach to, for example `My App Window Title` (should be of string type). Either this capability, `appTopLevelWindow` or `app` must be provided on session startup. | `My App Window Title` or `My App Window Title - .*` |
| Capability Name | Description | Example value |
| ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| platformName | Must be set to `windows` (case-insensitive). | `windows` |
| appium:app | The path to the application, or in case of an UWP app, `<package family name>!App`. It is also possible to set app to `Root`. In such case the session will be invoked without any explicit target application. Either this capability, `appTopLevelWindow` or `appTopLevelWindowTitleMatch` must be provided on session startup. | `C:\Windows\System32\notepad.exe`, `Microsoft.WindowsCalculator_8wekyb3d8bbwe!App` |
| appium:appArguments | Application arguments string, for example `/?`. | |
| appium:appTopLevelWindow | The hexadecimal handle of an existing application top level window to attach to, for example `0x12345` (should be of string type). Either this capability, `appTopLevelWindowTitleMatch` or `app` must be provided on session startup. | `0xC0B46` |
| appium:appTopLevelWindowTitleMatch | The title of an existing application top level window to attach to, for example `My App Window Title` (should be of string type). Either this capability, `appTopLevelWindow` or `app` must be provided on session startup. | `My App Window Title` or `My App Window Title - .*` |

## Getting Started

This driver currenlty is only available by building from source. Start the web driver service with:
This driver currenlty can be downloaded as an executable. Start the web driver service with:

```PowerShell
./FlaUI.WebDriver.exe --urls=http://localhost:4723/
Expand Down
11 changes: 11 additions & 0 deletions src/FlaUI.WebDriver.UITests/SessionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,17 @@ public void NewSession_MultipleMatchingAppTopLevelWindowTitleMatch_ReturnsError(
Assert.That(newSession, Throws.TypeOf<WebDriverArgumentException>().With.Message.EqualTo("Found multiple (2) processes with main window title matching 'FlaUI WPF Test App'"));
}

[Test, Explicit("GitHub actions runner doesn't have calculator installed")]
public void NewSession_UwpApp_IsSupported()
{
var driverOptions = FlaUIDriverOptions.App("Microsoft.WindowsCalculator_8wekyb3d8bbwe!App");
using var driver = new RemoteWebDriver(WebDriverFixture.WebDriverUrl, driverOptions);

var title = driver.Title;

Assert.That(title, Is.EqualTo("Calculator"));
}

[Test]
public void NewSession_AppTopLevelWindowTitleMatchNotFound_ReturnsError()
{
Expand Down
15 changes: 11 additions & 4 deletions src/FlaUI.WebDriver/Controllers/SessionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,20 @@ public async Task<ActionResult> CreateNewSession([FromBody] CreateSessionRequest
{
app = null;
}
else
{
else
{
capabilities.TryGetValue("appium:appArguments", out var appArguments);
try
{
var processStartInfo = new ProcessStartInfo(appPath, appArguments ?? "");
app = Core.Application.Launch(processStartInfo);
if (appPath.EndsWith("!App"))
{
app = Core.Application.LaunchStoreApp(appPath, appArguments);
}
else
{
var processStartInfo = new ProcessStartInfo(appPath, appArguments ?? "");
app = Core.Application.Launch(processStartInfo);
}
}
catch(Exception e)
{
Expand Down
Loading