Skip to content

Commit

Permalink
Loads of changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mattleibow committed Aug 26, 2024
1 parent f9b784f commit 8d196c9
Show file tree
Hide file tree
Showing 66 changed files with 956 additions and 392 deletions.
22 changes: 18 additions & 4 deletions DeviceRunners.sln
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,17 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{7FD9E644-B76
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{EE37724C-5FEF-46BB-AD80-CD002CC7FF54}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeviceTestingKitApp.UITests", "sample\test\DeviceTestingKitApp.UITests\DeviceTestingKitApp.UITests.csproj", "{7F8A6736-38CC-42DE-A609-399FC3C7FFEA}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeviceTestingKitApp.UITests.XunitTests", "sample\test\DeviceTestingKitApp.UITests\DeviceTestingKitApp.UITests.XunitTests.csproj", "{7F8A6736-38CC-42DE-A609-399FC3C7FFEA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeviceTestingKitApp.UITests.Windows", "sample\test\DeviceTestingKitApp.UITests.Windows\DeviceTestingKitApp.UITests.Windows.csproj", "{C2A34B21-6334-4B31-9617-D1648C6B0A50}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeviceTestingKitApp.UITests.XunitTests.Windows", "sample\test\DeviceTestingKitApp.UITests.Windows\DeviceTestingKitApp.UITests.XunitTests.Windows.csproj", "{C2A34B21-6334-4B31-9617-D1648C6B0A50}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeviceTestingKitApp.UITests.Android", "sample\test\DeviceTestingKitApp.UITests.Android\DeviceTestingKitApp.UITests.Android.csproj", "{34618A8D-7BA5-4999-8049-3220DC63648C}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeviceTestingKitApp.UITests.XunitTests.Android", "sample\test\DeviceTestingKitApp.UITests.Android\DeviceTestingKitApp.UITests.XunitTests.Android.csproj", "{34618A8D-7BA5-4999-8049-3220DC63648C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeviceRunners.Appium", "src\DeviceRunners.Appium\DeviceRunners.Appium.csproj", "{B1A52689-AE30-4136-9502-AD2B6A6D154A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeviceRunners.UIAutomation.Appium", "src\DeviceRunners.UIAutomation.Appium\DeviceRunners.UIAutomation.Appium.csproj", "{B1A52689-AE30-4136-9502-AD2B6A6D154A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeviceRunners.UIAutomation", "src\DeviceRunners.UIAutomation\DeviceRunners.UIAutomation.csproj", "{4B514D48-D89C-457D-B2DE-F7822A7225B9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeviceTestingKitApp.UITests.NUnitTests", "DeviceTestingKitApp.UITests.NUnitTests\DeviceTestingKitApp.UITests.NUnitTests.csproj", "{03A0F40A-9234-4DCE-AC34-0A1138525DD4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -161,6 +165,14 @@ Global
{B1A52689-AE30-4136-9502-AD2B6A6D154A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B1A52689-AE30-4136-9502-AD2B6A6D154A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B1A52689-AE30-4136-9502-AD2B6A6D154A}.Release|Any CPU.Build.0 = Release|Any CPU
{4B514D48-D89C-457D-B2DE-F7822A7225B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4B514D48-D89C-457D-B2DE-F7822A7225B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4B514D48-D89C-457D-B2DE-F7822A7225B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4B514D48-D89C-457D-B2DE-F7822A7225B9}.Release|Any CPU.Build.0 = Release|Any CPU
{03A0F40A-9234-4DCE-AC34-0A1138525DD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{03A0F40A-9234-4DCE-AC34-0A1138525DD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{03A0F40A-9234-4DCE-AC34-0A1138525DD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{03A0F40A-9234-4DCE-AC34-0A1138525DD4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -191,6 +203,8 @@ Global
{C2A34B21-6334-4B31-9617-D1648C6B0A50} = {EE37724C-5FEF-46BB-AD80-CD002CC7FF54}
{34618A8D-7BA5-4999-8049-3220DC63648C} = {EE37724C-5FEF-46BB-AD80-CD002CC7FF54}
{B1A52689-AE30-4136-9502-AD2B6A6D154A} = {DBF1C119-C96C-4DD3-810B-52451603475C}
{4B514D48-D89C-457D-B2DE-F7822A7225B9} = {DBF1C119-C96C-4DD3-810B-52451603475C}
{03A0F40A-9234-4DCE-AC34-0A1138525DD4} = {EE37724C-5FEF-46BB-AD80-CD002CC7FF54}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2DABD41C-B083-429E-AE1E-971CFF8DC199}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit.Analyzers" Version="3.9.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\src\DeviceRunners.UIAutomation.Appium\DeviceRunners.UIAutomation.Appium.csproj" />
<ProjectReference Include="..\src\DeviceRunners.UIAutomation\DeviceRunners.UIAutomation.csproj" />
</ItemGroup>

<ItemGroup>
<Using Include="NUnit.Framework" />
</ItemGroup>

</Project>
15 changes: 15 additions & 0 deletions DeviceTestingKitApp.UITests.NUnitTests/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace DeviceTestingKitApp.UITests.NUnitTests;

public class Tests
{
[SetUp]
public void Setup()
{
}

[Test]
public void Test1()
{
Assert.Pass();
}
}
2 changes: 1 addition & 1 deletion sample/test/DeviceTestingKitApp.UITests.Windows/_Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ namespace DeviceTestingKitApp.UITests;
public static partial class _Config
{
[ModuleInitializer]
public static void Run() => Current = "windows_msix";
public static void Run() => Current = "windows";
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using DeviceRunners.Appium;
using DeviceRunners.UIAutomation.Appium;

using OpenQA.Selenium.Appium.Enums;

Expand Down
30 changes: 15 additions & 15 deletions sample/test/DeviceTestingKitApp.UITests/BaseUITests.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using System.Runtime.CompilerServices;
using System.Xml.Linq;

using DeviceRunners.Appium;

using OpenQA.Selenium;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Windows;
using DeviceRunners.UIAutomation;
using DeviceRunners.UIAutomation.Appium;

using Xunit;
using Xunit.Abstractions;
Expand All @@ -16,40 +13,43 @@ namespace DeviceTestingKitApp.UITests;
[Collection(UITestsCollection.CollectionName)]
public abstract class BaseUITests : IDisposable
{
private readonly AppiumTest _appiumTest;
private readonly AppiumTestApp _appiumTestApp;
private readonly AutomationTestSuite _automationTestSuite;
private readonly ITest? _xunitTest;

public BaseUITests(UITestsFixture fixture, ITestOutputHelper output)
{
_appiumTest = fixture.AppiumTest;
_appiumTestApp = fixture.AppiumTest.GetApp(_Config.Current);

Driver = _appiumTestApp.Driver;
_automationTestSuite = fixture.TestSuite;
App = _automationTestSuite.StartApp(_Config.Current);
Output = output;

DeviceBy = new UITestsDeviceBy(Driver);

_xunitTest = GetTest(Output as TestOutputHelper);
}

protected AppiumDriver Driver { get; }
protected IAutomatedApp App { get; }

protected ITestOutputHelper Output { get; }

public void Dispose()
{
Output.WriteLine("Last page source:");
if (Driver.PageSource is string source && !string.IsNullOrWhiteSpace(source))
if (App.GetPageSource() is string source && !string.IsNullOrWhiteSpace(source))
Output.WriteLine(XDocument.Parse(source).ToString());
else
Output.WriteLine("Page source is empty");

Output.WriteLine("Last screenshot:");
if (Driver.GetScreenshot() is { } screenshot)
Output.WriteLine(screenshot.AsBase64EncodedString);
if (App.GetScreenshot() is { } screenshot)
{
Output.WriteLine(screenshot.ToBase64String());
}
else
{
Output.WriteLine("No screenshot available");
}

_automationTestSuite.StopApp(_Config.Current);
}

protected UITestsDeviceBy DeviceBy { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@
<ItemGroup>
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit.core" Version="2.6.6" ExcludeAssets="build;buildTransitive" />
<PackageReference Include="Appium.WebDriver" Version="5.0.0-rc.6" />
</ItemGroup>

<ItemGroup>
<ProjectCapability Remove="TestContainer" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\DeviceRunners.Appium\DeviceRunners.Appium.csproj" />
<ProjectReference Include="..\..\..\src\DeviceRunners.UIAutomation.Appium\DeviceRunners.UIAutomation.Appium.csproj" />
</ItemGroup>

</Project>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" PrivateAssets="all" />
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.5" PrivateAssets="all" />
<PackageReference Include="Appium.WebDriver" Version="5.0.0-rc.6" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(MSBuildThisFileDirectory)..\..\..\src\DeviceRunners.Appium\DeviceRunners.Appium.csproj" />
<ProjectReference Include="$(MSBuildThisFileDirectory)..\..\..\src\DeviceRunners.UIAutomation.Appium\DeviceRunners.UIAutomation.Appium.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
28 changes: 18 additions & 10 deletions sample/test/DeviceTestingKitApp.UITests/UITestsFixture.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using DeviceRunners.Appium;
using DeviceRunners.UIAutomation;
using DeviceRunners.UIAutomation.Appium;

using Xunit;
using Xunit.Abstractions;
Expand All @@ -10,21 +11,28 @@ public class UITestsFixture : IDisposable
{
public UITestsFixture(IMessageSink diagnosticMessageSink)
{
AppiumTest = AppiumTestBuilder.Create()
.UseServiceAddress("127.0.0.1", 4723)
.AddLogger(new MessageSinkLogger(diagnosticMessageSink))
.AddWindowsApp("windows_msix", "com.companyname.devicetestingkitapp_9zz4h110yvjzm!App")
.AddAndroidApp("android", "com.companyname.devicetestingkitapp", ".MainActivity")
//.AddAndroidApp("android", "D:\\GitHub\\DeviceRunners\\sample\\src\\DeviceTestingKitApp\\bin\\Release\\net8.0-android\\com.companyname.devicetestingkitapp-Signed.apk")
.Build();
var builder = AutomationTestSuiteBuilder.Create()
.AddAppium(options => options
.UseServiceAddress("127.0.0.1", 4723)
.AddLogger(new MessageSinkLogger(diagnosticMessageSink))
.AddAndroidApp("android", options => options
.UsePackageName("com.companyname.devicetestingkitapp")
.UseActivityName(".MainActivity"))
.AddWindowsApp("windows", options => options
.UseAppId("com.companyname.devicetestingkitapp_9zz4h110yvjzm!App")))
;
//.AddSelenium(options => options
// .AddWebApp("https://dot.net/"));

TestSuite = builder.Build();
}

public void Dispose()
{
AppiumTest.Dispose();
TestSuite.Dispose();
}

public AppiumTest AppiumTest { get; private set; }
public AutomationTestSuite TestSuite { get; private set; }

class MessageSinkLogger : IAppiumDiagnosticLogger
{
Expand Down
62 changes: 0 additions & 62 deletions src/DeviceRunners.Appium/AppiumTest.cs

This file was deleted.

41 changes: 0 additions & 41 deletions src/DeviceRunners.Appium/AppiumTestApp.cs

This file was deleted.

Loading

0 comments on commit 8d196c9

Please sign in to comment.