Skip to content

Commit cee32df

Browse files
authored
Merge pull request #15 from FlaUI/uwp-app-support
Add UWP app support
2 parents 651e548 + 3856842 commit cee32df

File tree

3 files changed

+30
-12
lines changed

3 files changed

+30
-12
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ FlaUI.WebDriver is a [W3C WebDriver2](https://www.w3.org/TR/webdriver2/) impleme
2121

2222
The following capabilities are supported:
2323

24-
| Capability Name | Description | Example value |
25-
| ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- |
26-
| platformName | Must be set to `windows` (case-insensitive). | `windows` |
27-
| 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` |
28-
| appium:appArguments | Application arguments string, for example `/?`. |
29-
| 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` |
30-
| 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 - .*` |
24+
| Capability Name | Description | Example value |
25+
| ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
26+
| platformName | Must be set to `windows` (case-insensitive). | `windows` |
27+
| 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` |
28+
| appium:appArguments | Application arguments string, for example `/?`. | |
29+
| 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` |
30+
| 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 - .*` |
3131

3232
## Getting Started
3333

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

3636
```PowerShell
3737
./FlaUI.WebDriver.exe --urls=http://localhost:4723/

src/FlaUI.WebDriver.UITests/SessionTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,17 @@ public void NewSession_MultipleMatchingAppTopLevelWindowTitleMatch_ReturnsError(
102102
Assert.That(newSession, Throws.TypeOf<WebDriverArgumentException>().With.Message.EqualTo("Found multiple (2) processes with main window title matching 'FlaUI WPF Test App'"));
103103
}
104104

105+
[Test, Explicit("GitHub actions runner doesn't have calculator installed")]
106+
public void NewSession_UwpApp_IsSupported()
107+
{
108+
var driverOptions = FlaUIDriverOptions.App("Microsoft.WindowsCalculator_8wekyb3d8bbwe!App");
109+
using var driver = new RemoteWebDriver(WebDriverFixture.WebDriverUrl, driverOptions);
110+
111+
var title = driver.Title;
112+
113+
Assert.That(title, Is.EqualTo("Calculator"));
114+
}
115+
105116
[Test]
106117
public void NewSession_AppTopLevelWindowTitleMatchNotFound_ReturnsError()
107118
{

src/FlaUI.WebDriver/Controllers/SessionController.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,20 @@ public async Task<ActionResult> CreateNewSession([FromBody] CreateSessionRequest
4848
{
4949
app = null;
5050
}
51-
else
52-
{
51+
else
52+
{
5353
capabilities.TryGetValue("appium:appArguments", out var appArguments);
5454
try
5555
{
56-
var processStartInfo = new ProcessStartInfo(appPath, appArguments ?? "");
57-
app = Core.Application.Launch(processStartInfo);
56+
if (appPath.EndsWith("!App"))
57+
{
58+
app = Core.Application.LaunchStoreApp(appPath, appArguments);
59+
}
60+
else
61+
{
62+
var processStartInfo = new ProcessStartInfo(appPath, appArguments ?? "");
63+
app = Core.Application.Launch(processStartInfo);
64+
}
5865
}
5966
catch(Exception e)
6067
{

0 commit comments

Comments
 (0)