Skip to content

Commit

Permalink
Merge branch 'main' into appium-new-command-timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
aristotelos authored Apr 18, 2024
2 parents ad6a4d4 + cee32df commit c3b3fca
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ 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 - .*` |
| appium:newCommandTimeout | The number of seconds the to wait for clients to send commands before deciding that the client has gone away and the session should shut down. Default one minute (60). | `120` |
| 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 - .*` |
| appium:newCommandTimeout | The number of seconds the to wait for clients to send commands before deciding that the client has gone away and the session should shut down. Default one minute (60). | `120` |

## 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
18 changes: 13 additions & 5 deletions src/FlaUI.WebDriver/Controllers/SessionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,21 @@ public async Task<ActionResult> CreateNewSession([FromBody] CreateSessionRequest
{
app = null;
}
else
{
bool hasArguments = capabilities.TryGetValue("appium:appArguments", out var appArguments);
else
{
bool hasArguments = capabilities.TryGetValue("appium:appArguments", out var appArgumentsValue);
var appArguments = hasArguments ? appArgumentsValue.GetString()! : "";
try
{
var processStartInfo = new ProcessStartInfo(appPath.GetString()!, hasArguments ? appArguments.GetString()! : "");
app = Core.Application.Launch(processStartInfo);
if (appPath.GetString()!.EndsWith("!App"))
{
app = Core.Application.LaunchStoreApp(appPath.GetString()!, appArguments);
}
else
{
var processStartInfo = new ProcessStartInfo(appPath.GetString()!, appArguments);
app = Core.Application.Launch(processStartInfo);
}
}
catch(Exception e)
{
Expand Down

0 comments on commit c3b3fca

Please sign in to comment.