Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding more comprehensive tests #28

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
A bunch more things
  • Loading branch information
mattleibow committed Sep 16, 2024
commit 6ecc875b72d563877a6461a495d68d1eed5c5000
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ namespace DeviceTestingKitApp.UITests.NUnitTests;
[TestFixture("android")]
[TestFixture("windows")]
[TestFixture("web")]
[TestFixture("web_playwright")]
[Parallelizable(ParallelScope.Fixtures)]
public abstract class BaseUITests
{
Original file line number Diff line number Diff line change
@@ -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!"));
}
@@ -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);
@@ -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++)
{
Original file line number Diff line number Diff line change
@@ -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");
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;
@@ -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();
Original file line number Diff line number Diff line change
@@ -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))
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
Loading