Skip to content

Commit

Permalink
A bunch more things
Browse files Browse the repository at this point in the history
  • Loading branch information
mattleibow committed Sep 16, 2024
1 parent 92ab789 commit 6ecc875
Show file tree
Hide file tree
Showing 35 changed files with 459 additions and 466 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace DeviceTestingKitApp.UITests.NUnitTests;
[TestFixture("android")]
[TestFixture("windows")]
[TestFixture("web")]
[TestFixture("web_playwright")]
[Parallelizable(ParallelScope.Fixtures)]
public abstract class BaseUITests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public MainPageTests(string appKey)
public void InitialStateIsCorrect()
{
var element = App.FindElement(by => by.Id("CounterButton"));
Assert.NotNull(element);

Assert.That(element.GetText(), Is.EqualTo("Click me!"));
}
Expand All @@ -21,6 +22,7 @@ public void InitialStateIsCorrect()
public async Task SingleIncrementIncrementsByOne()
{
var element = App.FindElement(by => by.Id("CounterButton"));
Assert.NotNull(element);

element.Click();
await Task.Delay(500);
Expand All @@ -36,6 +38,7 @@ public async Task SingleIncrementIncrementsByOne()
public async Task ClickingMultipleTimesKeepsIncrementing(int clicks, string text)
{
var element = App.FindElement(by => by.Id("CounterButton"));
Assert.NotNull(element);

for (var i = 0; i < clicks; i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public async Task IsReady()
using var playwright = await Playwright.CreateAsync();

await using var browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions { Channel = "msedge" });

var page = await browser.NewPageAsync();

await page.GotoAsync("https://playwright.dev/dotnet");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using DeviceRunners.UIAutomation;
using DeviceRunners.UIAutomation.Appium;
using DeviceRunners.UIAutomation.Playwright;
using DeviceRunners.UIAutomation.Selenium;

using NUnit.Framework.Internal;
Expand All @@ -23,6 +24,9 @@ public void OneTimeSetUp()
.UseAppId("com.companyname.devicetestingkitapp_9zz4h110yvjzm!App")))
.AddSelenium(selenium => selenium
.AddMicrosoftEdge("web", options => options
.UseInitialUrl("https://localhost:7096/")))
.AddPlaywright(playwright => playwright
.AddMicrosoftEdge("web_playwright", options => options
.UseInitialUrl("https://localhost:7096/")));

TestSuite = builder.Build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@

namespace DeviceRunners.UIAutomation.Appium;

public class AppiumClickCoordinatesCommand : AppiumElementCommand
public class AppiumClickCoordinatesCommand : AutomatedAppCommand<AppiumAutomatedApp>
{
public AppiumClickCoordinatesCommand()
: base(CommonCommandNames.ClickCoordinates)
{
}

public override object? Execute(AppiumAutomatedApp app, AppiumElement appiumElement, IReadOnlyDictionary<string, object> parameters)
public override object? Execute(AppiumAutomatedApp app, IReadOnlyDictionary<string, object>? parameters = null)
{
if (parameters is null)
throw new ArgumentException("No coordinates found in parameters", nameof(parameters));
if (!parameters.TryGetValue("x", out var x))
throw new ArgumentException("X coordinate not found in parameters", nameof(parameters));
if (!parameters.TryGetValue("y", out var y))
Expand Down
62 changes: 0 additions & 62 deletions src/DeviceRunners.UIAutomation.Playwright/AppiumAutomatedApp.cs

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace DeviceRunners.UIAutomation.Playwright;

public static partial class PlaywrightAutomationOptionsBuilderExtensions
{
public static PlaywrightAutomationOptionsBuilder AddMicrosoftEdge(this PlaywrightAutomationOptionsBuilder builder, string key, Action<EdgePlaywrightAutomatedAppOptionsBuilder> optionsAction)
{
var optionsBuilder = new EdgePlaywrightAutomatedAppOptionsBuilder(key);

optionsBuilder.AddDefaultPlaywrightCommands();
//optionsBuilder.AddDefaultAndroidPlaywrightCommands();

optionsAction(optionsBuilder);

builder.AddApp(key, optionsBuilder.Build());

return builder;
}
}
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
//namespace DeviceRunners.UIAutomation.Playwright;
namespace DeviceRunners.UIAutomation.Playwright;

//public static class AutomationTestSuiteBuilderExtensions
//{
// public static AutomationTestSuiteBuilder AddPlaywright(this AutomationTestSuiteBuilder builder, Action<PlaywrightAutomationOptionsBuilder> optionsAction)
// {
// var optionsBuilder = new PlaywrightAutomationOptionsBuilder();
public static class AutomationTestSuiteBuilderExtensions
{
public static AutomationTestSuiteBuilder AddPlaywright(this AutomationTestSuiteBuilder builder, Action<PlaywrightAutomationOptionsBuilder> optionsAction)
{
var optionsBuilder = new PlaywrightAutomationOptionsBuilder();

// optionsAction(optionsBuilder);
optionsAction(optionsBuilder);

// var playwright = new PlaywrightAutomationFramework(
// optionsBuilder.Options,
// optionsBuilder.Apps,
// new CompositeLogger(optionsBuilder.Loggers));
var playwright = new PlaywrightAutomationFramework(
optionsBuilder.Options,
optionsBuilder.Apps,
new CompositeLogger(optionsBuilder.Loggers));

// builder.AddAutomationFramework(playwright);
builder.AddAutomationFramework(playwright);

// return builder;
// }
return builder;
}

// class CompositeLogger : IPlaywrightDiagnosticLogger
// {
// private readonly List<IPlaywrightDiagnosticLogger> _loggers;
class CompositeLogger : IPlaywrightDiagnosticLogger
{
private readonly List<IPlaywrightDiagnosticLogger> _loggers;

// public CompositeLogger(IEnumerable<IPlaywrightDiagnosticLogger> loggers) =>
// _loggers = loggers.ToList();
public CompositeLogger(IEnumerable<IPlaywrightDiagnosticLogger> loggers) =>
_loggers = loggers.ToList();

// public void Log(string message)
// {
// foreach (var logger in _loggers)
// logger.Log(message);
// }
// }
//}
public void Log(string message)
{
foreach (var logger in _loggers)
logger.Log(message);
}
}
}
Loading

0 comments on commit 6ecc875

Please sign in to comment.