Skip to content

Commit

Permalink
Merge pull request #15 from FlaUI/uwp-app-support
Browse files Browse the repository at this point in the history
Add UWP app support
  • Loading branch information
aristotelos authored Apr 18, 2024
2 parents 651e548 + 3856842 commit cee32df
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
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

0 comments on commit cee32df

Please sign in to comment.