Skip to content

Commit

Permalink
Merge pull request #2 from FlaUI/test-github-actions
Browse files Browse the repository at this point in the history
Add GitHub actions to build and package
  • Loading branch information
aristotelos authored Mar 28, 2024
2 parents b46eced + 1712283 commit f38deb9
Show file tree
Hide file tree
Showing 18 changed files with 216 additions and 283 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: build

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:

build:

runs-on: windows-latest

env:
Configuration: Release

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x

- name: Restore dependencies
run: dotnet restore
working-directory: ./src

- name: Build
run: dotnet build --no-restore --configuration $env:Configuration
working-directory: ./src

- name: Test
run: dotnet test --no-build --configuration $env:Configuration --verbosity normal
working-directory: ./src

# Unfortunately, --no-build does not seem to work when we publish a specific project, so we use --no-restore instead
# Skip adding a web.config for IIS, as we will always use Kestrel (IsTransformWebConfigDisabled=true)
- name: Publish
run: dotnet publish FlaUI.WebDriver/FlaUI.WebDriver.csproj --no-restore --configuration $env:Configuration --self-contained /p:IsTransformWebConfigDisabled=true
working-directory: ./src

- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: FlaUI.WebDriver
path: ./src/FlaUI.WebDriver/bin/Release/win-x64/publish
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# FlaUI.WebDriver

[![build](https://github.com/FlaUI/FlaUI.WebDriver/actions/workflows/build.yml/badge.svg)](https://github.com/FlaUI/FlaUI.WebDriver/actions/workflows/build.yml)

FlaUI.WebDriver is a [W3C WebDriver2](https://www.w3.org/TR/webdriver2/) implementation using FlaUI's automation. It currently only supports UIA3.

> [!IMPORTANT]
Expand Down
4 changes: 2 additions & 2 deletions src/FlaUI.WebDriver.UITests/ElementTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ public void GetElementRect_Default_IsSupported()
var size = element.Size;

var windowLocation = driver.Manage().Window.Position;
Assert.That(location.X, Is.InRange(windowLocation.X + 254, windowLocation.X + 256));
Assert.That(location.Y, Is.InRange(windowLocation.Y + 133, windowLocation.Y + 135));
Assert.That(location.X, Is.InRange(windowLocation.X + 253, windowLocation.X + 257));
Assert.That(location.Y, Is.InRange(windowLocation.Y + 132, windowLocation.Y + 136));
Assert.That(size.Width, Is.EqualTo(120));
Assert.That(size.Height, Is.EqualTo(22));
}
Expand Down
5 changes: 5 additions & 0 deletions src/FlaUI.WebDriver.UITests/FlaUI.WebDriver.UITests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\FlaUI.WebDriver\FlaUI.WebDriver.csproj" />
<ProjectReference Include="..\TestApplications\WpfApplication\WpfApplication.csproj" />
</ItemGroup>

</Project>
4 changes: 1 addition & 3 deletions src/FlaUI.WebDriver.UITests/TestUtil/FlaUIDriverOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ namespace FlaUI.WebDriver.UITests.TestUtil
{
internal class FlaUIDriverOptions : DriverOptions
{
public const string TestAppPath = "..\\..\\..\\TestApplications\\WpfApplication\\bin\\WpfApplication.exe";

public override ICapabilities ToCapabilities()
{
return GenerateDesiredCapabilities(true);
}

public static FlaUIDriverOptions TestApp() => App(TestAppPath);
public static FlaUIDriverOptions TestApp() => App(TestApplication.FullPath);

public static DriverOptions RootApp() => App("Root");

Expand Down
3 changes: 1 addition & 2 deletions src/FlaUI.WebDriver.UITests/TestUtil/TestAppProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ namespace FlaUI.WebDriver.UITests.TestUtil
{
public class TestAppProcess : IDisposable
{
private const string TestAppPath = "..\\..\\..\\..\\TestApplications\\WpfApplication\\bin\\WpfApplication.exe";
private readonly Process _process;

public TestAppProcess()
{
_process = Process.Start(TestAppPath);
_process = Process.Start(TestApplication.FullPath);
while (_process.MainWindowHandle == IntPtr.Zero)
{
System.Threading.Thread.Sleep(100);
Expand Down
9 changes: 9 additions & 0 deletions src/FlaUI.WebDriver.UITests/TestUtil/TestApplication.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.IO;

namespace FlaUI.WebDriver.UITests.TestUtil
{
public static class TestApplication
{
public static string FullPath => Path.GetFullPath("..\\..\\..\\..\\TestApplications\\WpfApplication\\bin\\Release\\WpfApplication.exe");
}
}
2 changes: 1 addition & 1 deletion src/FlaUI.WebDriver.UITests/WebDriverFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace FlaUI.WebDriver.UITests
[SetUpFixture]
public class WebDriverFixture
{
public static readonly Uri WebDriverUrl = new Uri("http://localhost:4723/");
public static readonly Uri WebDriverUrl = new Uri("http://localhost:9723/");

private Process _webDriverProcess;

Expand Down
75 changes: 68 additions & 7 deletions src/FlaUI.WebDriver.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,98 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{3DFE78D4
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestApplications", "TestApplications", "{00BCF82A-388A-4DC9-A1E2-6D6D983BAEE3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfApplication", "TestApplications\WpfApplication\WpfApplication.csproj", "{C8276299-FA43-409B-A969-EF030AB56224}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FlaUI.WebDriver", "FlaUI.WebDriver\FlaUI.WebDriver.csproj", "{07FE5EE9-0104-42CE-A79D-88FD7D79B542}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FlaUI.WebDriver.UITests", "FlaUI.WebDriver.UITests\FlaUI.WebDriver.UITests.csproj", "{5315D9CF-DDA4-49AE-BA92-AB5814E61901}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WpfApplication", "TestApplications\WpfApplication\WpfApplication.csproj", "{23F0E331-C5AE-4D3D-B4E2-534D52E65CA0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4F6F2546-27D9-468C-AD80-1629B54139DA}"
ProjectSection(SolutionItems) = preProject
..\README.md = ..\README.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C8276299-FA43-409B-A969-EF030AB56224}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C8276299-FA43-409B-A969-EF030AB56224}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C8276299-FA43-409B-A969-EF030AB56224}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C8276299-FA43-409B-A969-EF030AB56224}.Release|Any CPU.Build.0 = Release|Any CPU
{07FE5EE9-0104-42CE-A79D-88FD7D79B542}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{07FE5EE9-0104-42CE-A79D-88FD7D79B542}.Debug|Any CPU.Build.0 = Debug|Any CPU
{07FE5EE9-0104-42CE-A79D-88FD7D79B542}.Debug|ARM.ActiveCfg = Debug|Any CPU
{07FE5EE9-0104-42CE-A79D-88FD7D79B542}.Debug|ARM.Build.0 = Debug|Any CPU
{07FE5EE9-0104-42CE-A79D-88FD7D79B542}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{07FE5EE9-0104-42CE-A79D-88FD7D79B542}.Debug|ARM64.Build.0 = Debug|Any CPU
{07FE5EE9-0104-42CE-A79D-88FD7D79B542}.Debug|x64.ActiveCfg = Debug|Any CPU
{07FE5EE9-0104-42CE-A79D-88FD7D79B542}.Debug|x64.Build.0 = Debug|Any CPU
{07FE5EE9-0104-42CE-A79D-88FD7D79B542}.Debug|x86.ActiveCfg = Debug|Any CPU
{07FE5EE9-0104-42CE-A79D-88FD7D79B542}.Debug|x86.Build.0 = Debug|Any CPU
{07FE5EE9-0104-42CE-A79D-88FD7D79B542}.Release|Any CPU.ActiveCfg = Release|Any CPU
{07FE5EE9-0104-42CE-A79D-88FD7D79B542}.Release|Any CPU.Build.0 = Release|Any CPU
{07FE5EE9-0104-42CE-A79D-88FD7D79B542}.Release|ARM.ActiveCfg = Release|Any CPU
{07FE5EE9-0104-42CE-A79D-88FD7D79B542}.Release|ARM.Build.0 = Release|Any CPU
{07FE5EE9-0104-42CE-A79D-88FD7D79B542}.Release|ARM64.ActiveCfg = Release|Any CPU
{07FE5EE9-0104-42CE-A79D-88FD7D79B542}.Release|ARM64.Build.0 = Release|Any CPU
{07FE5EE9-0104-42CE-A79D-88FD7D79B542}.Release|x64.ActiveCfg = Release|Any CPU
{07FE5EE9-0104-42CE-A79D-88FD7D79B542}.Release|x64.Build.0 = Release|Any CPU
{07FE5EE9-0104-42CE-A79D-88FD7D79B542}.Release|x86.ActiveCfg = Release|Any CPU
{07FE5EE9-0104-42CE-A79D-88FD7D79B542}.Release|x86.Build.0 = Release|Any CPU
{5315D9CF-DDA4-49AE-BA92-AB5814E61901}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5315D9CF-DDA4-49AE-BA92-AB5814E61901}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5315D9CF-DDA4-49AE-BA92-AB5814E61901}.Debug|ARM.ActiveCfg = Debug|Any CPU
{5315D9CF-DDA4-49AE-BA92-AB5814E61901}.Debug|ARM.Build.0 = Debug|Any CPU
{5315D9CF-DDA4-49AE-BA92-AB5814E61901}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{5315D9CF-DDA4-49AE-BA92-AB5814E61901}.Debug|ARM64.Build.0 = Debug|Any CPU
{5315D9CF-DDA4-49AE-BA92-AB5814E61901}.Debug|x64.ActiveCfg = Debug|Any CPU
{5315D9CF-DDA4-49AE-BA92-AB5814E61901}.Debug|x64.Build.0 = Debug|Any CPU
{5315D9CF-DDA4-49AE-BA92-AB5814E61901}.Debug|x86.ActiveCfg = Debug|Any CPU
{5315D9CF-DDA4-49AE-BA92-AB5814E61901}.Debug|x86.Build.0 = Debug|Any CPU
{5315D9CF-DDA4-49AE-BA92-AB5814E61901}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5315D9CF-DDA4-49AE-BA92-AB5814E61901}.Release|Any CPU.Build.0 = Release|Any CPU
{5315D9CF-DDA4-49AE-BA92-AB5814E61901}.Release|ARM.ActiveCfg = Release|Any CPU
{5315D9CF-DDA4-49AE-BA92-AB5814E61901}.Release|ARM.Build.0 = Release|Any CPU
{5315D9CF-DDA4-49AE-BA92-AB5814E61901}.Release|ARM64.ActiveCfg = Release|Any CPU
{5315D9CF-DDA4-49AE-BA92-AB5814E61901}.Release|ARM64.Build.0 = Release|Any CPU
{5315D9CF-DDA4-49AE-BA92-AB5814E61901}.Release|x64.ActiveCfg = Release|Any CPU
{5315D9CF-DDA4-49AE-BA92-AB5814E61901}.Release|x64.Build.0 = Release|Any CPU
{5315D9CF-DDA4-49AE-BA92-AB5814E61901}.Release|x86.ActiveCfg = Release|Any CPU
{5315D9CF-DDA4-49AE-BA92-AB5814E61901}.Release|x86.Build.0 = Release|Any CPU
{23F0E331-C5AE-4D3D-B4E2-534D52E65CA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{23F0E331-C5AE-4D3D-B4E2-534D52E65CA0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{23F0E331-C5AE-4D3D-B4E2-534D52E65CA0}.Debug|ARM.ActiveCfg = Debug|Any CPU
{23F0E331-C5AE-4D3D-B4E2-534D52E65CA0}.Debug|ARM.Build.0 = Debug|Any CPU
{23F0E331-C5AE-4D3D-B4E2-534D52E65CA0}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{23F0E331-C5AE-4D3D-B4E2-534D52E65CA0}.Debug|ARM64.Build.0 = Debug|Any CPU
{23F0E331-C5AE-4D3D-B4E2-534D52E65CA0}.Debug|x64.ActiveCfg = Debug|Any CPU
{23F0E331-C5AE-4D3D-B4E2-534D52E65CA0}.Debug|x64.Build.0 = Debug|Any CPU
{23F0E331-C5AE-4D3D-B4E2-534D52E65CA0}.Debug|x86.ActiveCfg = Debug|Any CPU
{23F0E331-C5AE-4D3D-B4E2-534D52E65CA0}.Debug|x86.Build.0 = Debug|Any CPU
{23F0E331-C5AE-4D3D-B4E2-534D52E65CA0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{23F0E331-C5AE-4D3D-B4E2-534D52E65CA0}.Release|Any CPU.Build.0 = Release|Any CPU
{23F0E331-C5AE-4D3D-B4E2-534D52E65CA0}.Release|ARM.ActiveCfg = Release|Any CPU
{23F0E331-C5AE-4D3D-B4E2-534D52E65CA0}.Release|ARM.Build.0 = Release|Any CPU
{23F0E331-C5AE-4D3D-B4E2-534D52E65CA0}.Release|ARM64.ActiveCfg = Release|Any CPU
{23F0E331-C5AE-4D3D-B4E2-534D52E65CA0}.Release|ARM64.Build.0 = Release|Any CPU
{23F0E331-C5AE-4D3D-B4E2-534D52E65CA0}.Release|x64.ActiveCfg = Release|Any CPU
{23F0E331-C5AE-4D3D-B4E2-534D52E65CA0}.Release|x64.Build.0 = Release|Any CPU
{23F0E331-C5AE-4D3D-B4E2-534D52E65CA0}.Release|x86.ActiveCfg = Release|Any CPU
{23F0E331-C5AE-4D3D-B4E2-534D52E65CA0}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{C8276299-FA43-409B-A969-EF030AB56224} = {00BCF82A-388A-4DC9-A1E2-6D6D983BAEE3}
{5315D9CF-DDA4-49AE-BA92-AB5814E61901} = {3DFE78D4-89EB-4CEE-A5D1-F5FDDED10959}
{23F0E331-C5AE-4D3D-B4E2-534D52E65CA0} = {00BCF82A-388A-4DC9-A1E2-6D6D983BAEE3}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F2B64231-45B2-4129-960A-9F26AFFD16AE}
Expand Down
12 changes: 12 additions & 0 deletions src/FlaUI.WebDriver/.config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "8.0.3",
"commands": [
"dotnet-ef"
]
}
}
}
9 changes: 8 additions & 1 deletion src/FlaUI.WebDriver/FlaUI.WebDriver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@
<PropertyGroup Label="Build">
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>preview</LangVersion>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
<PublishSingleFile>true</PublishSingleFile>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FlaUI.UIA3.Signed" Version="4.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>

<ItemGroup>
<Content Update="appsettings.*.json" CopyToPublishDirectory="Never" />
</ItemGroup>

</Project>
50 changes: 28 additions & 22 deletions src/FlaUI.WebDriver/Program.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using System.IO;
using System.Reflection;
using FlaUI.WebDriver;
using Microsoft.OpenApi.Models;

namespace FlaUI.WebDriver
var builder = WebApplication.CreateBuilder(args);

builder.Services.AddSingleton<ISessionRepository, SessionRepository>();

builder.Services.Configure<RouteOptions>(options => options.LowercaseUrls = true);
builder.Services.AddControllers(options =>
options.Filters.Add(new WebDriverResponseExceptionFilter()));

builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(c =>
{
public class Program
{
public static void Main(string[] args)
{
string assemblyDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!;
Directory.SetCurrentDirectory(assemblyDir);

CreateHostBuilder(args).Build().Run();
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
c.SwaggerDoc("v1", new OpenApiInfo { Title = "FlaUI.WebDriver", Version = "v1" });
});

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "FlaUI.WebDriver v1"));
}

app.UseAuthorization();

app.MapControllers();

app.Run();
65 changes: 0 additions & 65 deletions src/FlaUI.WebDriver/Startup.cs

This file was deleted.

Loading

0 comments on commit f38deb9

Please sign in to comment.