From 57dd4b66c8eb1fa5122103351388d9af0c4d935f Mon Sep 17 00:00:00 2001 From: Oleg Mozhey Date: Sat, 17 Feb 2024 23:10:02 +0400 Subject: [PATCH 01/20] Prepare base structure of a ui bindings project --- ...vioral.Automation.Bindings.UI.Tests.csproj | 33 ++++++++++++++ .../Configurations/Hooks.cs | 23 ++++++++++ .../Configurations/WebElement.cs | 20 +++++++++ .../WebElementStorageService.cs | 12 ++++++ .../UIBindingsCanBeUsedTests.feature | 6 +++ .../specflow.json | 16 +++++++ .../Abstractions/ElementSelector.cs | 8 ++++ .../Abstractions/IBrowser.cs | 7 +++ .../Abstractions/IButtonElement.cs | 7 +++ .../Abstractions/ICheckboxElement.cs | 6 +++ .../Abstractions/IDropdownElement.cs | 6 +++ .../Abstractions/IFileChooser.cs | 6 +++ .../Abstractions/IInputWebElement.cs | 6 +++ .../Abstractions/ILabelElement.cs | 7 +++ .../Abstractions/IPage.cs | 11 +++++ .../Abstractions/ITableWrapper.cs | 7 +++ .../Abstractions/IWebElement.cs | 10 +++++ .../Abstractions/IWebElementStorageService.cs | 13 ++++++ .../Behavioral.Automation.Bindings.UI.csproj | 33 ++++++++++++++ .../Bindings/ButtonBindings.cs | 40 +++++++++++++++++ .../Bindings/CheckboxBindings.cs | 15 +++++++ .../Bindings/DropdownBinding.cs | 16 +++++++ .../Bindings/InputBinding.cs | 17 ++++++++ .../Bindings/LabelBindings.cs | 20 +++++++++ .../Bindings/NavigationBinding.cs | 28 ++++++++++++ .../Bindings/PageBinding.cs | 21 +++++++++ .../Bindings/TableBinding.cs | 21 +++++++++ .../CHANGELOG.md | 11 +++++ .../Context/WebContext.cs | 15 +++++++ .../ElementTransformations.cs | 43 +++++++++++++++++++ Behavioral.Automation.Bindings.UI/README.md | 1 + Behavioral.Automation.sln | 16 +++++++ 32 files changed, 501 insertions(+) create mode 100644 Behavioral.Automation.Bindings.UI.Tests/Behavioral.Automation.Bindings.UI.Tests.csproj create mode 100644 Behavioral.Automation.Bindings.UI.Tests/Configurations/Hooks.cs create mode 100644 Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs create mode 100644 Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElementStorageService.cs create mode 100644 Behavioral.Automation.Bindings.UI.Tests/UIBindingsCanBeUsedTests.feature create mode 100644 Behavioral.Automation.Bindings.UI.Tests/specflow.json create mode 100644 Behavioral.Automation.Bindings.UI/Abstractions/ElementSelector.cs create mode 100644 Behavioral.Automation.Bindings.UI/Abstractions/IBrowser.cs create mode 100644 Behavioral.Automation.Bindings.UI/Abstractions/IButtonElement.cs create mode 100644 Behavioral.Automation.Bindings.UI/Abstractions/ICheckboxElement.cs create mode 100644 Behavioral.Automation.Bindings.UI/Abstractions/IDropdownElement.cs create mode 100644 Behavioral.Automation.Bindings.UI/Abstractions/IFileChooser.cs create mode 100644 Behavioral.Automation.Bindings.UI/Abstractions/IInputWebElement.cs create mode 100644 Behavioral.Automation.Bindings.UI/Abstractions/ILabelElement.cs create mode 100644 Behavioral.Automation.Bindings.UI/Abstractions/IPage.cs create mode 100644 Behavioral.Automation.Bindings.UI/Abstractions/ITableWrapper.cs create mode 100644 Behavioral.Automation.Bindings.UI/Abstractions/IWebElement.cs create mode 100644 Behavioral.Automation.Bindings.UI/Abstractions/IWebElementStorageService.cs create mode 100644 Behavioral.Automation.Bindings.UI/Behavioral.Automation.Bindings.UI.csproj create mode 100644 Behavioral.Automation.Bindings.UI/Bindings/ButtonBindings.cs create mode 100644 Behavioral.Automation.Bindings.UI/Bindings/CheckboxBindings.cs create mode 100644 Behavioral.Automation.Bindings.UI/Bindings/DropdownBinding.cs create mode 100644 Behavioral.Automation.Bindings.UI/Bindings/InputBinding.cs create mode 100644 Behavioral.Automation.Bindings.UI/Bindings/LabelBindings.cs create mode 100644 Behavioral.Automation.Bindings.UI/Bindings/NavigationBinding.cs create mode 100644 Behavioral.Automation.Bindings.UI/Bindings/PageBinding.cs create mode 100644 Behavioral.Automation.Bindings.UI/Bindings/TableBinding.cs create mode 100644 Behavioral.Automation.Bindings.UI/CHANGELOG.md create mode 100644 Behavioral.Automation.Bindings.UI/Context/WebContext.cs create mode 100644 Behavioral.Automation.Bindings.UI/ElementTransformations/ElementTransformations.cs create mode 100644 Behavioral.Automation.Bindings.UI/README.md diff --git a/Behavioral.Automation.Bindings.UI.Tests/Behavioral.Automation.Bindings.UI.Tests.csproj b/Behavioral.Automation.Bindings.UI.Tests/Behavioral.Automation.Bindings.UI.Tests.csproj new file mode 100644 index 00000000..64495414 --- /dev/null +++ b/Behavioral.Automation.Bindings.UI.Tests/Behavioral.Automation.Bindings.UI.Tests.csproj @@ -0,0 +1,33 @@ + + + + net6.0 + enable + enable + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + Always + + + + diff --git a/Behavioral.Automation.Bindings.UI.Tests/Configurations/Hooks.cs b/Behavioral.Automation.Bindings.UI.Tests/Configurations/Hooks.cs new file mode 100644 index 00000000..7f4dfc9c --- /dev/null +++ b/Behavioral.Automation.Bindings.UI.Tests/Configurations/Hooks.cs @@ -0,0 +1,23 @@ +using Behavioral.Automation.Bindings.UI.Abstractions; +using BoDi; +using TechTalk.SpecFlow; + +namespace Behavioral.Automation.Bindings.UI.Tests.Configurations; + +[Binding] +public class Configuration +{ + private readonly IObjectContainer _objectContainer; + + public Configuration(IObjectContainer objectContainer) + { + _objectContainer = objectContainer; + } + + [BeforeScenario()] + public void ResolveDependencyInjectionInterfaces() + { + _objectContainer.RegisterTypeAs(); + } + +} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs b/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs new file mode 100644 index 00000000..024d4619 --- /dev/null +++ b/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs @@ -0,0 +1,20 @@ +using Behavioral.Automation.Bindings.UI.Abstractions; +using Behavioral.Automation.Bindings.UI.Context; + +namespace Behavioral.Automation.Bindings.UI.Tests.Configurations; + +public class WebElement : IWebElement, IButtonElement +{ + public WebContext WebContext { get; } + public ElementSelector ElementSelector { get; } + public string? Description { get; set; } + public Task ClickAsync() + { + return Task.Run(() => Console.WriteLine("Clicked button")); + } + + public Task ShouldBecomeVisibleAsync() + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElementStorageService.cs b/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElementStorageService.cs new file mode 100644 index 00000000..49b718b7 --- /dev/null +++ b/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElementStorageService.cs @@ -0,0 +1,12 @@ +using Behavioral.Automation.Bindings.UI.Abstractions; + +namespace Behavioral.Automation.Bindings.UI.Tests.Configurations; + +public class WebElementStorageService : IWebElementStorageService +{ + public T Get(string locatorKey) + { + IWebElement webElement = new WebElement(); + return (T) webElement; + } +} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI.Tests/UIBindingsCanBeUsedTests.feature b/Behavioral.Automation.Bindings.UI.Tests/UIBindingsCanBeUsedTests.feature new file mode 100644 index 00000000..e7000db8 --- /dev/null +++ b/Behavioral.Automation.Bindings.UI.Tests/UIBindingsCanBeUsedTests.feature @@ -0,0 +1,6 @@ +Feature: Test cases to check that UI bindings can be used by specflow framework + The test cases check only configuration of BDD framework - dependencies and abstraction classes + The implementation of Interfaces should be tested in other projects + +Scenario: Simple button click test + Given "Test" button has been clicked \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI.Tests/specflow.json b/Behavioral.Automation.Bindings.UI.Tests/specflow.json new file mode 100644 index 00000000..492c3f17 --- /dev/null +++ b/Behavioral.Automation.Bindings.UI.Tests/specflow.json @@ -0,0 +1,16 @@ +{ + "bindingCulture": { + "language": "en-us" + }, + "language": { + "feature": "en-us" + }, + "runtime": { + "missingOrPendingStepsOutcome": "Error" + }, + "stepAssemblies": [ + { + "assembly": "Behavioral.Automation.Bindings.UI" + } + ] +} diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/ElementSelector.cs b/Behavioral.Automation.Bindings.UI/Abstractions/ElementSelector.cs new file mode 100644 index 00000000..605f006d --- /dev/null +++ b/Behavioral.Automation.Bindings.UI/Abstractions/ElementSelector.cs @@ -0,0 +1,8 @@ +namespace Behavioral.Automation.Bindings.UI.Abstractions; + +public class ElementSelector +{ + public string? IdSelector { get; set; } + + public string? XpathSelector { get; set; } +} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IBrowser.cs b/Behavioral.Automation.Bindings.UI/Abstractions/IBrowser.cs new file mode 100644 index 00000000..d63f5ab0 --- /dev/null +++ b/Behavioral.Automation.Bindings.UI/Abstractions/IBrowser.cs @@ -0,0 +1,7 @@ +namespace Behavioral.Automation.Bindings.UI.Abstractions; + +public interface IBrowser +{ + public Task NewPageAsync(); + public Task CloseAsync(); +} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IButtonElement.cs b/Behavioral.Automation.Bindings.UI/Abstractions/IButtonElement.cs new file mode 100644 index 00000000..4543cd1e --- /dev/null +++ b/Behavioral.Automation.Bindings.UI/Abstractions/IButtonElement.cs @@ -0,0 +1,7 @@ +namespace Behavioral.Automation.Bindings.UI.Abstractions; + +public interface IButtonElement +{ + public Task ClickAsync(); + public Task ShouldBecomeVisibleAsync(); +} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/ICheckboxElement.cs b/Behavioral.Automation.Bindings.UI/Abstractions/ICheckboxElement.cs new file mode 100644 index 00000000..be460216 --- /dev/null +++ b/Behavioral.Automation.Bindings.UI/Abstractions/ICheckboxElement.cs @@ -0,0 +1,6 @@ +namespace Behavioral.Automation.Bindings.UI.Abstractions; + +public interface ICheckboxElement +{ + public Task ClickAsync(); +} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IDropdownElement.cs b/Behavioral.Automation.Bindings.UI/Abstractions/IDropdownElement.cs new file mode 100644 index 00000000..0f4458a8 --- /dev/null +++ b/Behavioral.Automation.Bindings.UI/Abstractions/IDropdownElement.cs @@ -0,0 +1,6 @@ +namespace Behavioral.Automation.Bindings.UI.Abstractions; + +public interface IDropdownElement +{ + public Task OpenDropdownAndSelectAsync(string item); +} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IFileChooser.cs b/Behavioral.Automation.Bindings.UI/Abstractions/IFileChooser.cs new file mode 100644 index 00000000..26b8a918 --- /dev/null +++ b/Behavioral.Automation.Bindings.UI/Abstractions/IFileChooser.cs @@ -0,0 +1,6 @@ +namespace Behavioral.Automation.Bindings.UI.Abstractions; + +public interface IFileChooser +{ + public Task UploadFileAsync(string filePath); +} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IInputWebElement.cs b/Behavioral.Automation.Bindings.UI/Abstractions/IInputWebElement.cs new file mode 100644 index 00000000..dcf7a782 --- /dev/null +++ b/Behavioral.Automation.Bindings.UI/Abstractions/IInputWebElement.cs @@ -0,0 +1,6 @@ +namespace Behavioral.Automation.Bindings.UI.Abstractions; + +public interface IInputWebElement +{ + public Task TypeAsync(string text); +} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/ILabelElement.cs b/Behavioral.Automation.Bindings.UI/Abstractions/ILabelElement.cs new file mode 100644 index 00000000..4a9bce4f --- /dev/null +++ b/Behavioral.Automation.Bindings.UI/Abstractions/ILabelElement.cs @@ -0,0 +1,7 @@ +namespace Behavioral.Automation.Bindings.UI.Abstractions; + +public interface ILabelElement +{ + public Task ShouldHaveTextAsync(string text); + public Task ShouldBecomeVisibleAsync(); +} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IPage.cs b/Behavioral.Automation.Bindings.UI/Abstractions/IPage.cs new file mode 100644 index 00000000..06468bfb --- /dev/null +++ b/Behavioral.Automation.Bindings.UI/Abstractions/IPage.cs @@ -0,0 +1,11 @@ +namespace Behavioral.Automation.Bindings.UI.Abstractions; + +public interface IPage +{ + public Task GotoAsync(string url); + public Task GoToApplicationUrlAsync(); + public Task ToHaveTitleAsync(string title); + public Task RunAndWaitForFileChooserAsync(Func action); + public Task ScreenshotAsync(string path); + +} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/ITableWrapper.cs b/Behavioral.Automation.Bindings.UI/Abstractions/ITableWrapper.cs new file mode 100644 index 00000000..c3236128 --- /dev/null +++ b/Behavioral.Automation.Bindings.UI/Abstractions/ITableWrapper.cs @@ -0,0 +1,7 @@ +namespace Behavioral.Automation.Bindings.UI.Abstractions; + +public interface ITableWrapper +{ + public Task ShouldBecomeVisibleAsync(); + public Task ShouldBecomeVisibleAsync(int delay); +} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IWebElement.cs b/Behavioral.Automation.Bindings.UI/Abstractions/IWebElement.cs new file mode 100644 index 00000000..ff8d0b06 --- /dev/null +++ b/Behavioral.Automation.Bindings.UI/Abstractions/IWebElement.cs @@ -0,0 +1,10 @@ +using Behavioral.Automation.Bindings.UI.Context; + +namespace Behavioral.Automation.Bindings.UI.Abstractions; + +public interface IWebElement +{ + public WebContext WebContext { get; } + public ElementSelector ElementSelector { get; } + public string? Description { get; set; } +} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IWebElementStorageService.cs b/Behavioral.Automation.Bindings.UI/Abstractions/IWebElementStorageService.cs new file mode 100644 index 00000000..80040a59 --- /dev/null +++ b/Behavioral.Automation.Bindings.UI/Abstractions/IWebElementStorageService.cs @@ -0,0 +1,13 @@ +namespace Behavioral.Automation.Bindings.UI.Abstractions; + +public interface IWebElementStorageService +{ + static readonly Dictionary RegisteredImplementations = new(); + static void RegisterWebElementImplementationAs() where TType : class, TInterface + { + RegisteredImplementations.Add(typeof(TInterface), typeof(TType)); + } + + T Get(string locatorKey); + +} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Behavioral.Automation.Bindings.UI.csproj b/Behavioral.Automation.Bindings.UI/Behavioral.Automation.Bindings.UI.csproj new file mode 100644 index 00000000..339d5d4c --- /dev/null +++ b/Behavioral.Automation.Bindings.UI/Behavioral.Automation.Bindings.UI.csproj @@ -0,0 +1,33 @@ + + + + net6.0 + enable + enable + AnyCPU + Behavioral.Automation.Bindings.UI + 0.0.1 + Quantori Inc. + tas + Quantori Inc. + Apache-2.0 + true + Quantori BDD is a automation framework that makes use of a wide array of existing grammatical structures, including abstractions, implementations, and bindings, while also offering strong customization options for any implementations. + + The whole Framework is divided into the following parts: + - Bindings (Abstractions including configuration interfaces) + - Implementation of abstractions + - Project configurations + - Feature files + + https://github.com/quantori/Behavioral.Automation + true + + + + + + + + + diff --git a/Behavioral.Automation.Bindings.UI/Bindings/ButtonBindings.cs b/Behavioral.Automation.Bindings.UI/Bindings/ButtonBindings.cs new file mode 100644 index 00000000..a424e9e0 --- /dev/null +++ b/Behavioral.Automation.Bindings.UI/Bindings/ButtonBindings.cs @@ -0,0 +1,40 @@ +using Behavioral.Automation.Bindings.UI.Abstractions; +using Behavioral.Automation.Bindings.UI.Context; +using TechTalk.SpecFlow; + +namespace Behavioral.Automation.Bindings.UI.Bindings; + +[Binding] +public class ButtonBindings +{ + + private readonly WebContext _webContext; + + public ButtonBindings(WebContext webContext) + { + _webContext = webContext; + } + + [Given(@"""(.+?)"" button has been clicked")] + [When(@"user clicks on ""(.+?)"" button")] + public async Task ClickOnButton(IButtonElement button) + { + await button.ClickAsync(); + } + + [Then(@"""(.+?)"" button should become visible")] + public async Task ButtonShouldBecomeVisible(IButtonElement button) + { + await button.ShouldBecomeVisibleAsync(); + } + + [When(@"user uploads ""(.*)"" file after clicking on ""(.*)"" button")] + public async Task WhenUserUploadsFileAfterClickingOnButton(string filePath, IButtonElement button) + { + var fileChooser = await _webContext.Page.RunAndWaitForFileChooserAsync(async () => + { + await button.ClickAsync(); + }); + await fileChooser.UploadFileAsync(filePath); + } +} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Bindings/CheckboxBindings.cs b/Behavioral.Automation.Bindings.UI/Bindings/CheckboxBindings.cs new file mode 100644 index 00000000..7854f5c5 --- /dev/null +++ b/Behavioral.Automation.Bindings.UI/Bindings/CheckboxBindings.cs @@ -0,0 +1,15 @@ +using Behavioral.Automation.Bindings.UI.Abstractions; +using TechTalk.SpecFlow; + +namespace Behavioral.Automation.Bindings.UI.Bindings; + +[Binding] +public class CheckboxBindings +{ + [Given(@"""(.+?)"" checkbox was clicked")] + [When(@"user clicks on ""(.+?)"" checkbox")] + public async Task ClickOnCheckbox(ICheckboxElement checkbox) + { + await checkbox.ClickAsync(); + } +} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Bindings/DropdownBinding.cs b/Behavioral.Automation.Bindings.UI/Bindings/DropdownBinding.cs new file mode 100644 index 00000000..678e4b64 --- /dev/null +++ b/Behavioral.Automation.Bindings.UI/Bindings/DropdownBinding.cs @@ -0,0 +1,16 @@ +using Behavioral.Automation.Bindings.UI.Abstractions; +using TechTalk.SpecFlow; + +namespace Behavioral.Automation.Bindings.UI.Bindings; + +[Binding] +public class DropdownBinding +{ + + [Given(@"""(.*)"" dropdown was opened and ""(.*)"" was selected in dropdown menu")] + [When(@"user opens ""(.*)"" dropdown and selects ""(.*)"" in dropdown menu")] + public async Task WhenUserSelectsInDropdownRegex(IDropdownElement dropdown, string itemText) + { + await dropdown.OpenDropdownAndSelectAsync(itemText); + } +} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Bindings/InputBinding.cs b/Behavioral.Automation.Bindings.UI/Bindings/InputBinding.cs new file mode 100644 index 00000000..e4377104 --- /dev/null +++ b/Behavioral.Automation.Bindings.UI/Bindings/InputBinding.cs @@ -0,0 +1,17 @@ +using Behavioral.Automation.Bindings.UI.Abstractions; +using TechTalk.SpecFlow; + +namespace Behavioral.Automation.Bindings.UI.Bindings; + +[Binding] +public class InputBinding +{ + + + [Given(@"""(.+?)"" text was entered into ""(.+?)"" input")] + [When(@"user enters ""(.+?)"" into ""(.+?)"" input")] + public async Task FillInput(string text, IInputWebElement input) + { + await input.TypeAsync(text); + } +} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Bindings/LabelBindings.cs b/Behavioral.Automation.Bindings.UI/Bindings/LabelBindings.cs new file mode 100644 index 00000000..3b661f78 --- /dev/null +++ b/Behavioral.Automation.Bindings.UI/Bindings/LabelBindings.cs @@ -0,0 +1,20 @@ +using Behavioral.Automation.Bindings.UI.Abstractions; +using TechTalk.SpecFlow; + +namespace Behavioral.Automation.Bindings.UI.Bindings; + +[Binding] +public class LabelBindings +{ + [Then(@"""(.+?)"" label should have ""(.+?)"" text")] + public async Task CheckLabelText(ILabelElement label, string text) + { + await label.ShouldHaveTextAsync(text); + } + + [Then(@"""(.+?)"" label should become visible")] + public async Task CheckLabelVisibility(ILabelElement label) + { + await label.ShouldBecomeVisibleAsync(); + } +} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Bindings/NavigationBinding.cs b/Behavioral.Automation.Bindings.UI/Bindings/NavigationBinding.cs new file mode 100644 index 00000000..aac58231 --- /dev/null +++ b/Behavioral.Automation.Bindings.UI/Bindings/NavigationBinding.cs @@ -0,0 +1,28 @@ +using Behavioral.Automation.Bindings.UI.Context; +using TechTalk.SpecFlow; + +namespace Behavioral.Automation.Bindings.UI.Bindings; + +[Binding] +public class NavigationBinding +{ + private readonly WebContext _webContext; + + public NavigationBinding(WebContext webContext) + { + _webContext = webContext; + } + + [Given(@"URL ""(.+?)"" was opened")] + [When(@"user opens URL ""(.+?)""")] + public async Task GivenUrlIsOpened(string url) + { + await _webContext.Page.GotoAsync(url); + } + + [Given("application URL was opened")] + public async Task GivenApplicationUrlIsOpened() + { + await _webContext.Page.GoToApplicationUrlAsync(); + } +} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Bindings/PageBinding.cs b/Behavioral.Automation.Bindings.UI/Bindings/PageBinding.cs new file mode 100644 index 00000000..5c7c9ee8 --- /dev/null +++ b/Behavioral.Automation.Bindings.UI/Bindings/PageBinding.cs @@ -0,0 +1,21 @@ +using Behavioral.Automation.Bindings.UI.Context; +using TechTalk.SpecFlow; + +namespace Behavioral.Automation.Bindings.UI.Bindings; + +[Binding] +public class PageBinding +{ + private readonly WebContext _webContext; + + public PageBinding(WebContext webContext) + { + _webContext = webContext; + } + + [Then(@"page title should become ""(.+?)""")] + public async Task ThenPageTitleShouldBe(string title) + { + await _webContext.Page.ToHaveTitleAsync(title); + } +} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Bindings/TableBinding.cs b/Behavioral.Automation.Bindings.UI/Bindings/TableBinding.cs new file mode 100644 index 00000000..f501279e --- /dev/null +++ b/Behavioral.Automation.Bindings.UI/Bindings/TableBinding.cs @@ -0,0 +1,21 @@ +using Behavioral.Automation.Bindings.UI.Abstractions; +using TechTalk.SpecFlow; + +namespace Behavioral.Automation.Bindings.UI.Bindings; + +[Binding] +public class TableBinding +{ + + [Then(@"""(.*)"" table should become visible$")] + public async Task ThenTableShouldBecomeVisible(ITableWrapper table) + { + await table.ShouldBecomeVisibleAsync(); + } + + [Then(@"""(.*)"" table should become visible within ""(.*)"" seconds")] + public async Task ThenTableShouldBecomeVisible(ITableWrapper table, int seconds) + { + await table.ShouldBecomeVisibleAsync(seconds); + } +} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/CHANGELOG.md b/Behavioral.Automation.Bindings.UI/CHANGELOG.md new file mode 100644 index 00000000..17d851e9 --- /dev/null +++ b/Behavioral.Automation.Bindings.UI/CHANGELOG.md @@ -0,0 +1,11 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +[0.0.1] - 17-02-2024 +### Added +- A few Button, Checkbox, Dropdown, Input, Label, Navigation, Page and Table bindings +- Abstractions for WebElements and Configuration classes (for example, IWebElementStorageService) +- ElementTransformations class \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Context/WebContext.cs b/Behavioral.Automation.Bindings.UI/Context/WebContext.cs new file mode 100644 index 00000000..a8913a8f --- /dev/null +++ b/Behavioral.Automation.Bindings.UI/Context/WebContext.cs @@ -0,0 +1,15 @@ +using Behavioral.Automation.Bindings.UI.Abstractions; + +namespace Behavioral.Automation.Bindings.UI.Context; + +/* +WebContext holds UI-related instances that can be reused across steps: +1. Browser +2. Tab (coming soon) +3. Page + */ +public class WebContext +{ + public IBrowser Browser { get; set; } + public IPage Page { get; set; } +} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/ElementTransformations/ElementTransformations.cs b/Behavioral.Automation.Bindings.UI/ElementTransformations/ElementTransformations.cs new file mode 100644 index 00000000..6db93734 --- /dev/null +++ b/Behavioral.Automation.Bindings.UI/ElementTransformations/ElementTransformations.cs @@ -0,0 +1,43 @@ +using Behavioral.Automation.Bindings.UI.Abstractions; +using TechTalk.SpecFlow; + +namespace Behavioral.Automation.Bindings.UI.ElementTransformations; + +[Binding] +public class ElementTransformations +{ + private readonly IWebElementStorageService _webElementStorageService; + + public ElementTransformations(IWebElementStorageService webElementStorageService) + { + _webElementStorageService = webElementStorageService; + } + + [StepArgumentTransformation] + public IInputWebElement GetInputElement(string caption) + { + var element = _webElementStorageService.Get(caption + "Input"); + return element; + } + + [StepArgumentTransformation] + public ICheckboxElement GetCheckboxElement(string caption) + { + var element = _webElementStorageService.Get(caption + "Checkbox"); + return element; + } + + [StepArgumentTransformation] + public IButtonElement GetButtonElement(string caption) + { + var element = _webElementStorageService.Get(caption + "Button"); + return element; + } + + [StepArgumentTransformation] + public ITableWrapper GetTableElement(string caption) + { + var element = _webElementStorageService.Get(caption + "Table"); + return element; + } +} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/README.md b/Behavioral.Automation.Bindings.UI/README.md new file mode 100644 index 00000000..2fd9f957 --- /dev/null +++ b/Behavioral.Automation.Bindings.UI/README.md @@ -0,0 +1 @@ +TBD \ No newline at end of file diff --git a/Behavioral.Automation.sln b/Behavioral.Automation.sln index c13a2b0c..f0a4b49e 100644 --- a/Behavioral.Automation.sln +++ b/Behavioral.Automation.sln @@ -26,6 +26,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UITests", "Behavioral.Autom EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{FA8E07DE-0779-44A0-AFF2-2C2573DD6611}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Behavioral.Automation.Bindings.UI", "Behavioral.Automation.Bindings.UI\Behavioral.Automation.Bindings.UI.csproj", "{DB675416-81CA-40EA-A1D9-F45E75248F74}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Behavioral.Automation.Buildings.UI", "Behavioral.Automation.Buildings.UI", "{C6D1A214-4D90-4973-83A0-4D1D1EA5DE30}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Behavioral.Automation.Bindings.UI.Tests", "Behavioral.Automation.Bindings.UI.Tests\Behavioral.Automation.Bindings.UI.Tests.csproj", "{D536A13B-0F79-4F01-9A8D-CAAD4A3811CD}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -64,6 +70,14 @@ Global {1498E9EA-13DE-4C6A-AB63-960D226F6FCE}.Debug|Any CPU.Build.0 = Debug|Any CPU {1498E9EA-13DE-4C6A-AB63-960D226F6FCE}.Release|Any CPU.ActiveCfg = Release|Any CPU {1498E9EA-13DE-4C6A-AB63-960D226F6FCE}.Release|Any CPU.Build.0 = Release|Any CPU + {DB675416-81CA-40EA-A1D9-F45E75248F74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DB675416-81CA-40EA-A1D9-F45E75248F74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DB675416-81CA-40EA-A1D9-F45E75248F74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DB675416-81CA-40EA-A1D9-F45E75248F74}.Release|Any CPU.Build.0 = Release|Any CPU + {D536A13B-0F79-4F01-9A8D-CAAD4A3811CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D536A13B-0F79-4F01-9A8D-CAAD4A3811CD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D536A13B-0F79-4F01-9A8D-CAAD4A3811CD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D536A13B-0F79-4F01-9A8D-CAAD4A3811CD}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -77,6 +91,8 @@ Global {BB7AC02C-03FD-4F17-B4A9-CDECC1A63DA5} = {430C8D20-03B9-4268-A6BC-F008F4DC2CD1} {FA8E07DE-0779-44A0-AFF2-2C2573DD6611} = {2A26C467-6A03-4942-9F9B-62F77F992F70} {1498E9EA-13DE-4C6A-AB63-960D226F6FCE} = {FA8E07DE-0779-44A0-AFF2-2C2573DD6611} + {DB675416-81CA-40EA-A1D9-F45E75248F74} = {C6D1A214-4D90-4973-83A0-4D1D1EA5DE30} + {D536A13B-0F79-4F01-9A8D-CAAD4A3811CD} = {C6D1A214-4D90-4973-83A0-4D1D1EA5DE30} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {724FD185-E1F2-44BD-89EA-DFD1DBF6453A} From c0ddfd9c83468470aa535daba617e067acb18c46 Mon Sep 17 00:00:00 2001 From: Oleg Mozhey Date: Sat, 17 Feb 2024 23:22:31 +0400 Subject: [PATCH 02/20] styling --- .../Abstractions/{IInputWebElement.cs => IInputElement.cs} | 2 +- Behavioral.Automation.Bindings.UI/Bindings/InputBinding.cs | 2 +- .../ElementTransformations/ElementTransformations.cs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) rename Behavioral.Automation.Bindings.UI/Abstractions/{IInputWebElement.cs => IInputElement.cs} (75%) diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IInputWebElement.cs b/Behavioral.Automation.Bindings.UI/Abstractions/IInputElement.cs similarity index 75% rename from Behavioral.Automation.Bindings.UI/Abstractions/IInputWebElement.cs rename to Behavioral.Automation.Bindings.UI/Abstractions/IInputElement.cs index dcf7a782..c334fb99 100644 --- a/Behavioral.Automation.Bindings.UI/Abstractions/IInputWebElement.cs +++ b/Behavioral.Automation.Bindings.UI/Abstractions/IInputElement.cs @@ -1,6 +1,6 @@ namespace Behavioral.Automation.Bindings.UI.Abstractions; -public interface IInputWebElement +public interface IInputElement { public Task TypeAsync(string text); } \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Bindings/InputBinding.cs b/Behavioral.Automation.Bindings.UI/Bindings/InputBinding.cs index e4377104..991164de 100644 --- a/Behavioral.Automation.Bindings.UI/Bindings/InputBinding.cs +++ b/Behavioral.Automation.Bindings.UI/Bindings/InputBinding.cs @@ -10,7 +10,7 @@ public class InputBinding [Given(@"""(.+?)"" text was entered into ""(.+?)"" input")] [When(@"user enters ""(.+?)"" into ""(.+?)"" input")] - public async Task FillInput(string text, IInputWebElement input) + public async Task FillInput(string text, IInputElement input) { await input.TypeAsync(text); } diff --git a/Behavioral.Automation.Bindings.UI/ElementTransformations/ElementTransformations.cs b/Behavioral.Automation.Bindings.UI/ElementTransformations/ElementTransformations.cs index 6db93734..ce771ce1 100644 --- a/Behavioral.Automation.Bindings.UI/ElementTransformations/ElementTransformations.cs +++ b/Behavioral.Automation.Bindings.UI/ElementTransformations/ElementTransformations.cs @@ -14,9 +14,9 @@ public ElementTransformations(IWebElementStorageService webElementStorageService } [StepArgumentTransformation] - public IInputWebElement GetInputElement(string caption) + public IInputElement GetInputElement(string caption) { - var element = _webElementStorageService.Get(caption + "Input"); + var element = _webElementStorageService.Get(caption + "Input"); return element; } From 3716b097a313ac13153dd1a555212df3a165f59f Mon Sep 17 00:00:00 2001 From: Oleg Mozhey Date: Sun, 18 Feb 2024 09:56:39 +0400 Subject: [PATCH 03/20] update selenium version --- .../Behavioral.Automation/Behavioral.Automation.csproj | 4 ++-- .../Behavioral.Automation/Services/DriverService.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Behavioral.Automation.Selenium/Behavioral.Automation/Behavioral.Automation.csproj b/Behavioral.Automation.Selenium/Behavioral.Automation/Behavioral.Automation.csproj index 7ce209aa..0280e5a0 100644 --- a/Behavioral.Automation.Selenium/Behavioral.Automation/Behavioral.Automation.csproj +++ b/Behavioral.Automation.Selenium/Behavioral.Automation/Behavioral.Automation.csproj @@ -36,8 +36,8 @@ The whole automation code is divided into the following parts: runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all diff --git a/Behavioral.Automation.Selenium/Behavioral.Automation/Services/DriverService.cs b/Behavioral.Automation.Selenium/Behavioral.Automation/Services/DriverService.cs index f5d9863e..c52e304d 100644 --- a/Behavioral.Automation.Selenium/Behavioral.Automation/Services/DriverService.cs +++ b/Behavioral.Automation.Selenium/Behavioral.Automation/Services/DriverService.cs @@ -270,7 +270,7 @@ public string MakeScreenShot() .Where(x => !Path.GetInvalidFileNameChars().Contains(x)) .ToArray()) + ".png"; Screenshot screenshot = ((ITakesScreenshot)Driver).GetScreenshot(); - screenshot.SaveAsFile(fileName, ScreenshotImageFormat.Png); + screenshot.SaveAsFile(fileName); return fileName; } From 3bd5cbcf006c4cd2ec62204b666684294325d873 Mon Sep 17 00:00:00 2001 From: Oleg Mozhey Date: Sun, 18 Feb 2024 10:06:18 +0400 Subject: [PATCH 04/20] version update --- .../Behavioral.Automation.DemoBindings.csproj | 4 ++-- .../Behavioral.Automation.DemoScenarios.csproj | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Behavioral.Automation.Selenium/Behavioral.Automation.DemoBindings/Behavioral.Automation.DemoBindings.csproj b/Behavioral.Automation.Selenium/Behavioral.Automation.DemoBindings/Behavioral.Automation.DemoBindings.csproj index 9a776b1f..85755345 100644 --- a/Behavioral.Automation.Selenium/Behavioral.Automation.DemoBindings/Behavioral.Automation.DemoBindings.csproj +++ b/Behavioral.Automation.Selenium/Behavioral.Automation.DemoBindings/Behavioral.Automation.DemoBindings.csproj @@ -10,8 +10,8 @@ - - + + diff --git a/Behavioral.Automation.Selenium/Behavioral.Automation.DemoScenarios/Behavioral.Automation.DemoScenarios.csproj b/Behavioral.Automation.Selenium/Behavioral.Automation.DemoScenarios/Behavioral.Automation.DemoScenarios.csproj index a421ef74..93cf8860 100644 --- a/Behavioral.Automation.Selenium/Behavioral.Automation.DemoScenarios/Behavioral.Automation.DemoScenarios.csproj +++ b/Behavioral.Automation.Selenium/Behavioral.Automation.DemoScenarios/Behavioral.Automation.DemoScenarios.csproj @@ -10,7 +10,7 @@ - + From aa259742b86397db792326b0d1e7c24fcab74aab Mon Sep 17 00:00:00 2001 From: Oleg Mozhey Date: Mon, 19 Feb 2024 15:46:37 +0400 Subject: [PATCH 05/20] Remove printing to Console in multithreading mode --- .../Configurations/WebElement.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs b/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs index 024d4619..da3ed3a8 100644 --- a/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs +++ b/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs @@ -10,7 +10,7 @@ public class WebElement : IWebElement, IButtonElement public string? Description { get; set; } public Task ClickAsync() { - return Task.Run(() => Console.WriteLine("Clicked button")); + return Task.Delay(50); } public Task ShouldBecomeVisibleAsync() From d41ce3061f9557c8d6420eee0edfc194e71400bd Mon Sep 17 00:00:00 2001 From: Oleg Mozhey Date: Mon, 19 Feb 2024 17:16:37 +0400 Subject: [PATCH 06/20] Fixed elements inheritance --- .../Configurations/WebElement.cs | 11 ++++++----- .../Abstractions/IButtonElement.cs | 3 +-- .../Abstractions/ICheckboxElement.cs | 2 +- .../Abstractions/IDropdownElement.cs | 2 +- .../Abstractions/IInputElement.cs | 2 +- .../Abstractions/ILabelElement.cs | 3 +-- .../Abstractions/ITableWrapper.cs | 3 +-- .../Abstractions/IWebElement.cs | 1 + 8 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs b/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs index da3ed3a8..3b9b8bbf 100644 --- a/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs +++ b/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs @@ -1,17 +1,18 @@ using Behavioral.Automation.Bindings.UI.Abstractions; using Behavioral.Automation.Bindings.UI.Context; +using Microsoft.Playwright; +using IPage = Microsoft.Playwright.IPage; namespace Behavioral.Automation.Bindings.UI.Tests.Configurations; -public class WebElement : IWebElement, IButtonElement +/* + * Shared code between all web Elements + */ +public class WebElement: IWebElement { public WebContext WebContext { get; } public ElementSelector ElementSelector { get; } public string? Description { get; set; } - public Task ClickAsync() - { - return Task.Delay(50); - } public Task ShouldBecomeVisibleAsync() { diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IButtonElement.cs b/Behavioral.Automation.Bindings.UI/Abstractions/IButtonElement.cs index 4543cd1e..6242b054 100644 --- a/Behavioral.Automation.Bindings.UI/Abstractions/IButtonElement.cs +++ b/Behavioral.Automation.Bindings.UI/Abstractions/IButtonElement.cs @@ -1,7 +1,6 @@ namespace Behavioral.Automation.Bindings.UI.Abstractions; -public interface IButtonElement +public interface IButtonElement : IWebElement { public Task ClickAsync(); - public Task ShouldBecomeVisibleAsync(); } \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/ICheckboxElement.cs b/Behavioral.Automation.Bindings.UI/Abstractions/ICheckboxElement.cs index be460216..76288212 100644 --- a/Behavioral.Automation.Bindings.UI/Abstractions/ICheckboxElement.cs +++ b/Behavioral.Automation.Bindings.UI/Abstractions/ICheckboxElement.cs @@ -1,6 +1,6 @@ namespace Behavioral.Automation.Bindings.UI.Abstractions; -public interface ICheckboxElement +public interface ICheckboxElement : IWebElement { public Task ClickAsync(); } \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IDropdownElement.cs b/Behavioral.Automation.Bindings.UI/Abstractions/IDropdownElement.cs index 0f4458a8..0f2b5626 100644 --- a/Behavioral.Automation.Bindings.UI/Abstractions/IDropdownElement.cs +++ b/Behavioral.Automation.Bindings.UI/Abstractions/IDropdownElement.cs @@ -1,6 +1,6 @@ namespace Behavioral.Automation.Bindings.UI.Abstractions; -public interface IDropdownElement +public interface IDropdownElement : IWebElement { public Task OpenDropdownAndSelectAsync(string item); } \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IInputElement.cs b/Behavioral.Automation.Bindings.UI/Abstractions/IInputElement.cs index c334fb99..c7db7916 100644 --- a/Behavioral.Automation.Bindings.UI/Abstractions/IInputElement.cs +++ b/Behavioral.Automation.Bindings.UI/Abstractions/IInputElement.cs @@ -1,6 +1,6 @@ namespace Behavioral.Automation.Bindings.UI.Abstractions; -public interface IInputElement +public interface IInputElement : IWebElement { public Task TypeAsync(string text); } \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/ILabelElement.cs b/Behavioral.Automation.Bindings.UI/Abstractions/ILabelElement.cs index 4a9bce4f..593165c8 100644 --- a/Behavioral.Automation.Bindings.UI/Abstractions/ILabelElement.cs +++ b/Behavioral.Automation.Bindings.UI/Abstractions/ILabelElement.cs @@ -1,7 +1,6 @@ namespace Behavioral.Automation.Bindings.UI.Abstractions; -public interface ILabelElement +public interface ILabelElement : IWebElement { public Task ShouldHaveTextAsync(string text); - public Task ShouldBecomeVisibleAsync(); } \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/ITableWrapper.cs b/Behavioral.Automation.Bindings.UI/Abstractions/ITableWrapper.cs index c3236128..c288299f 100644 --- a/Behavioral.Automation.Bindings.UI/Abstractions/ITableWrapper.cs +++ b/Behavioral.Automation.Bindings.UI/Abstractions/ITableWrapper.cs @@ -1,7 +1,6 @@ namespace Behavioral.Automation.Bindings.UI.Abstractions; -public interface ITableWrapper +public interface ITableWrapper : IWebElement { - public Task ShouldBecomeVisibleAsync(); public Task ShouldBecomeVisibleAsync(int delay); } \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IWebElement.cs b/Behavioral.Automation.Bindings.UI/Abstractions/IWebElement.cs index ff8d0b06..44f29eec 100644 --- a/Behavioral.Automation.Bindings.UI/Abstractions/IWebElement.cs +++ b/Behavioral.Automation.Bindings.UI/Abstractions/IWebElement.cs @@ -7,4 +7,5 @@ public interface IWebElement public WebContext WebContext { get; } public ElementSelector ElementSelector { get; } public string? Description { get; set; } + public Task ShouldBecomeVisibleAsync(); } \ No newline at end of file From 6a102ecbd14347915c81a503ed6d1f75fd19cb10 Mon Sep 17 00:00:00 2001 From: Oleg Mozhey Date: Mon, 19 Feb 2024 17:16:53 +0400 Subject: [PATCH 07/20] fixed import --- .../Configurations/WebElement.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs b/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs index 3b9b8bbf..8e811677 100644 --- a/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs +++ b/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs @@ -1,7 +1,5 @@ using Behavioral.Automation.Bindings.UI.Abstractions; using Behavioral.Automation.Bindings.UI.Context; -using Microsoft.Playwright; -using IPage = Microsoft.Playwright.IPage; namespace Behavioral.Automation.Bindings.UI.Tests.Configurations; From e5ddc1243cb41a6814acc0e992b16fd3fefe8212 Mon Sep 17 00:00:00 2001 From: Oleg Mozhey Date: Tue, 20 Feb 2024 13:35:27 +0400 Subject: [PATCH 08/20] Moved visibility checking methods to IWebElement --- .../Configurations/WebElement.cs | 12 +++++++++++- .../Abstractions/ITableWrapper.cs | 1 - .../Abstractions/IWebElement.cs | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs b/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs index 8e811677..7566793e 100644 --- a/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs +++ b/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs @@ -12,7 +12,17 @@ public class WebElement: IWebElement public ElementSelector ElementSelector { get; } public string? Description { get; set; } - public Task ShouldBecomeVisibleAsync() + public async Task ShouldBecomeVisibleAsync() + { + // defaultDelay = 300 is just an example of idea that we will have default delay for all elements + // and ability to specify delay in test steps if we have some taking time loading + // (for example, because of data processing) + var defaultDelay = 300; + await ShouldBecomeVisibleAsync(defaultDelay); + throw new NotImplementedException(); + } + + public async Task ShouldBecomeVisibleAsync(int delay) { throw new NotImplementedException(); } diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/ITableWrapper.cs b/Behavioral.Automation.Bindings.UI/Abstractions/ITableWrapper.cs index c288299f..8b9f51bf 100644 --- a/Behavioral.Automation.Bindings.UI/Abstractions/ITableWrapper.cs +++ b/Behavioral.Automation.Bindings.UI/Abstractions/ITableWrapper.cs @@ -2,5 +2,4 @@ public interface ITableWrapper : IWebElement { - public Task ShouldBecomeVisibleAsync(int delay); } \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IWebElement.cs b/Behavioral.Automation.Bindings.UI/Abstractions/IWebElement.cs index 44f29eec..e777f0af 100644 --- a/Behavioral.Automation.Bindings.UI/Abstractions/IWebElement.cs +++ b/Behavioral.Automation.Bindings.UI/Abstractions/IWebElement.cs @@ -8,4 +8,5 @@ public interface IWebElement public ElementSelector ElementSelector { get; } public string? Description { get; set; } public Task ShouldBecomeVisibleAsync(); + public Task ShouldBecomeVisibleAsync(int delay); } \ No newline at end of file From 961d887ce330cb6a4f94820d819993c2c7a11b29 Mon Sep 17 00:00:00 2001 From: Oleg Mozhey Date: Tue, 20 Feb 2024 13:38:46 +0400 Subject: [PATCH 09/20] Renamed ShouldBecomeVisible to IsVisible --- .../Configurations/WebElement.cs | 6 +++--- .../Abstractions/IWebElement.cs | 4 ++-- .../Bindings/ButtonBindings.cs | 2 +- Behavioral.Automation.Bindings.UI/Bindings/LabelBindings.cs | 2 +- Behavioral.Automation.Bindings.UI/Bindings/TableBinding.cs | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs b/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs index 7566793e..3ee11853 100644 --- a/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs +++ b/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs @@ -12,17 +12,17 @@ public class WebElement: IWebElement public ElementSelector ElementSelector { get; } public string? Description { get; set; } - public async Task ShouldBecomeVisibleAsync() + public async Task IsVisibleAsync() { // defaultDelay = 300 is just an example of idea that we will have default delay for all elements // and ability to specify delay in test steps if we have some taking time loading // (for example, because of data processing) var defaultDelay = 300; - await ShouldBecomeVisibleAsync(defaultDelay); + await IsVisibleAsync(defaultDelay); throw new NotImplementedException(); } - public async Task ShouldBecomeVisibleAsync(int delay) + public async Task IsVisibleAsync(int delay) { throw new NotImplementedException(); } diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IWebElement.cs b/Behavioral.Automation.Bindings.UI/Abstractions/IWebElement.cs index e777f0af..6932c876 100644 --- a/Behavioral.Automation.Bindings.UI/Abstractions/IWebElement.cs +++ b/Behavioral.Automation.Bindings.UI/Abstractions/IWebElement.cs @@ -7,6 +7,6 @@ public interface IWebElement public WebContext WebContext { get; } public ElementSelector ElementSelector { get; } public string? Description { get; set; } - public Task ShouldBecomeVisibleAsync(); - public Task ShouldBecomeVisibleAsync(int delay); + public Task IsVisibleAsync(); + public Task IsVisibleAsync(int delay); } \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Bindings/ButtonBindings.cs b/Behavioral.Automation.Bindings.UI/Bindings/ButtonBindings.cs index a424e9e0..83bda179 100644 --- a/Behavioral.Automation.Bindings.UI/Bindings/ButtonBindings.cs +++ b/Behavioral.Automation.Bindings.UI/Bindings/ButtonBindings.cs @@ -25,7 +25,7 @@ public async Task ClickOnButton(IButtonElement button) [Then(@"""(.+?)"" button should become visible")] public async Task ButtonShouldBecomeVisible(IButtonElement button) { - await button.ShouldBecomeVisibleAsync(); + await button.IsVisibleAsync(); } [When(@"user uploads ""(.*)"" file after clicking on ""(.*)"" button")] diff --git a/Behavioral.Automation.Bindings.UI/Bindings/LabelBindings.cs b/Behavioral.Automation.Bindings.UI/Bindings/LabelBindings.cs index 3b661f78..f9985fbc 100644 --- a/Behavioral.Automation.Bindings.UI/Bindings/LabelBindings.cs +++ b/Behavioral.Automation.Bindings.UI/Bindings/LabelBindings.cs @@ -15,6 +15,6 @@ public async Task CheckLabelText(ILabelElement label, string text) [Then(@"""(.+?)"" label should become visible")] public async Task CheckLabelVisibility(ILabelElement label) { - await label.ShouldBecomeVisibleAsync(); + await label.IsVisibleAsync(); } } \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Bindings/TableBinding.cs b/Behavioral.Automation.Bindings.UI/Bindings/TableBinding.cs index f501279e..3b242aa6 100644 --- a/Behavioral.Automation.Bindings.UI/Bindings/TableBinding.cs +++ b/Behavioral.Automation.Bindings.UI/Bindings/TableBinding.cs @@ -10,12 +10,12 @@ public class TableBinding [Then(@"""(.*)"" table should become visible$")] public async Task ThenTableShouldBecomeVisible(ITableWrapper table) { - await table.ShouldBecomeVisibleAsync(); + await table.IsVisibleAsync(); } [Then(@"""(.*)"" table should become visible within ""(.*)"" seconds")] public async Task ThenTableShouldBecomeVisible(ITableWrapper table, int seconds) { - await table.ShouldBecomeVisibleAsync(seconds); + await table.IsVisibleAsync(seconds); } } \ No newline at end of file From bc009fd7101e98af05ec0a4b82ffe2d278f4abe5 Mon Sep 17 00:00:00 2001 From: Oleg Mozhey Date: Tue, 20 Feb 2024 19:28:21 +0400 Subject: [PATCH 10/20] fixed based on colleague suggestions --- .../Configurations/Hooks.cs | 3 +-- .../Configurations/WebElement.cs | 3 +-- .../UIBindingsCanBeUsedTests.feature | 8 ++++---- .../Abstractions/ElementSelector.cs | 2 +- .../Abstractions/IBrowser.cs | 2 +- .../Abstractions/IInputElement.cs | 2 +- Behavioral.Automation.Bindings.UI/Abstractions/IPage.cs | 5 ++--- .../Abstractions/IWebElement.cs | 2 +- .../Abstractions/IWebElementStorageService.cs | 6 +++--- .../Bindings/ButtonBindings.cs | 5 ++--- .../Bindings/DropdownBinding.cs | 1 - .../Bindings/InputBinding.cs | 4 +--- .../Bindings/LabelBindings.cs | 2 +- .../Bindings/NavigationBinding.cs | 2 +- Behavioral.Automation.Bindings.UI/Bindings/PageBinding.cs | 2 +- .../Bindings/TableBinding.cs | 3 +-- .../ElementTransformations/ElementTransformations.cs | 6 +++--- 17 files changed, 25 insertions(+), 33 deletions(-) diff --git a/Behavioral.Automation.Bindings.UI.Tests/Configurations/Hooks.cs b/Behavioral.Automation.Bindings.UI.Tests/Configurations/Hooks.cs index 7f4dfc9c..5e7c64be 100644 --- a/Behavioral.Automation.Bindings.UI.Tests/Configurations/Hooks.cs +++ b/Behavioral.Automation.Bindings.UI.Tests/Configurations/Hooks.cs @@ -14,10 +14,9 @@ public Configuration(IObjectContainer objectContainer) _objectContainer = objectContainer; } - [BeforeScenario()] + [BeforeScenario] public void ResolveDependencyInjectionInterfaces() { _objectContainer.RegisterTypeAs(); } - } \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs b/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs index 3ee11853..cc4982af 100644 --- a/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs +++ b/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs @@ -6,7 +6,7 @@ namespace Behavioral.Automation.Bindings.UI.Tests.Configurations; /* * Shared code between all web Elements */ -public class WebElement: IWebElement +public class WebElement : IWebElement { public WebContext WebContext { get; } public ElementSelector ElementSelector { get; } @@ -19,7 +19,6 @@ public async Task IsVisibleAsync() // (for example, because of data processing) var defaultDelay = 300; await IsVisibleAsync(defaultDelay); - throw new NotImplementedException(); } public async Task IsVisibleAsync(int delay) diff --git a/Behavioral.Automation.Bindings.UI.Tests/UIBindingsCanBeUsedTests.feature b/Behavioral.Automation.Bindings.UI.Tests/UIBindingsCanBeUsedTests.feature index e7000db8..d8e61809 100644 --- a/Behavioral.Automation.Bindings.UI.Tests/UIBindingsCanBeUsedTests.feature +++ b/Behavioral.Automation.Bindings.UI.Tests/UIBindingsCanBeUsedTests.feature @@ -1,6 +1,6 @@ Feature: Test cases to check that UI bindings can be used by specflow framework - The test cases check only configuration of BDD framework - dependencies and abstraction classes - The implementation of Interfaces should be tested in other projects +The test cases check only configuration of BDD framework - dependencies and abstraction classes +The implementation of Interfaces should be tested in other projects -Scenario: Simple button click test - Given "Test" button has been clicked \ No newline at end of file + Scenario: Simple button click test + Given "Test" button has been clicked \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/ElementSelector.cs b/Behavioral.Automation.Bindings.UI/Abstractions/ElementSelector.cs index 605f006d..4ecd862e 100644 --- a/Behavioral.Automation.Bindings.UI/Abstractions/ElementSelector.cs +++ b/Behavioral.Automation.Bindings.UI/Abstractions/ElementSelector.cs @@ -3,6 +3,6 @@ public class ElementSelector { public string? IdSelector { get; set; } - + public string? XpathSelector { get; set; } } \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IBrowser.cs b/Behavioral.Automation.Bindings.UI/Abstractions/IBrowser.cs index d63f5ab0..c12bd5f4 100644 --- a/Behavioral.Automation.Bindings.UI/Abstractions/IBrowser.cs +++ b/Behavioral.Automation.Bindings.UI/Abstractions/IBrowser.cs @@ -2,6 +2,6 @@ public interface IBrowser { - public Task NewPageAsync(); + public Task OpenNewPageAsync(); public Task CloseAsync(); } \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IInputElement.cs b/Behavioral.Automation.Bindings.UI/Abstractions/IInputElement.cs index c7db7916..9f868cc7 100644 --- a/Behavioral.Automation.Bindings.UI/Abstractions/IInputElement.cs +++ b/Behavioral.Automation.Bindings.UI/Abstractions/IInputElement.cs @@ -2,5 +2,5 @@ public interface IInputElement : IWebElement { - public Task TypeAsync(string text); + public Task InputTextAsync(string text); } \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IPage.cs b/Behavioral.Automation.Bindings.UI/Abstractions/IPage.cs index 06468bfb..1d00ebcc 100644 --- a/Behavioral.Automation.Bindings.UI/Abstractions/IPage.cs +++ b/Behavioral.Automation.Bindings.UI/Abstractions/IPage.cs @@ -2,10 +2,9 @@ public interface IPage { - public Task GotoAsync(string url); + public Task GoToUrlAsync(string url); public Task GoToApplicationUrlAsync(); - public Task ToHaveTitleAsync(string title); + public Task HaveTitleAsync(string title); public Task RunAndWaitForFileChooserAsync(Func action); public Task ScreenshotAsync(string path); - } \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IWebElement.cs b/Behavioral.Automation.Bindings.UI/Abstractions/IWebElement.cs index 6932c876..d764a5c9 100644 --- a/Behavioral.Automation.Bindings.UI/Abstractions/IWebElement.cs +++ b/Behavioral.Automation.Bindings.UI/Abstractions/IWebElement.cs @@ -5,7 +5,7 @@ namespace Behavioral.Automation.Bindings.UI.Abstractions; public interface IWebElement { public WebContext WebContext { get; } - public ElementSelector ElementSelector { get; } + public ElementSelector ElementSelector { get; } public string? Description { get; set; } public Task IsVisibleAsync(); public Task IsVisibleAsync(int delay); diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IWebElementStorageService.cs b/Behavioral.Automation.Bindings.UI/Abstractions/IWebElementStorageService.cs index 80040a59..fa8bf4c1 100644 --- a/Behavioral.Automation.Bindings.UI/Abstractions/IWebElementStorageService.cs +++ b/Behavioral.Automation.Bindings.UI/Abstractions/IWebElementStorageService.cs @@ -2,12 +2,12 @@ public interface IWebElementStorageService { - static readonly Dictionary RegisteredImplementations = new(); + static readonly Dictionary RegisteredElements = new(); + static void RegisterWebElementImplementationAs() where TType : class, TInterface { - RegisteredImplementations.Add(typeof(TInterface), typeof(TType)); + RegisteredElements.Add(typeof(TInterface), typeof(TType)); } T Get(string locatorKey); - } \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Bindings/ButtonBindings.cs b/Behavioral.Automation.Bindings.UI/Bindings/ButtonBindings.cs index 83bda179..98de2c39 100644 --- a/Behavioral.Automation.Bindings.UI/Bindings/ButtonBindings.cs +++ b/Behavioral.Automation.Bindings.UI/Bindings/ButtonBindings.cs @@ -7,7 +7,6 @@ namespace Behavioral.Automation.Bindings.UI.Bindings; [Binding] public class ButtonBindings { - private readonly WebContext _webContext; public ButtonBindings(WebContext webContext) @@ -21,13 +20,13 @@ public async Task ClickOnButton(IButtonElement button) { await button.ClickAsync(); } - + [Then(@"""(.+?)"" button should become visible")] public async Task ButtonShouldBecomeVisible(IButtonElement button) { await button.IsVisibleAsync(); } - + [When(@"user uploads ""(.*)"" file after clicking on ""(.*)"" button")] public async Task WhenUserUploadsFileAfterClickingOnButton(string filePath, IButtonElement button) { diff --git a/Behavioral.Automation.Bindings.UI/Bindings/DropdownBinding.cs b/Behavioral.Automation.Bindings.UI/Bindings/DropdownBinding.cs index 678e4b64..70588657 100644 --- a/Behavioral.Automation.Bindings.UI/Bindings/DropdownBinding.cs +++ b/Behavioral.Automation.Bindings.UI/Bindings/DropdownBinding.cs @@ -6,7 +6,6 @@ namespace Behavioral.Automation.Bindings.UI.Bindings; [Binding] public class DropdownBinding { - [Given(@"""(.*)"" dropdown was opened and ""(.*)"" was selected in dropdown menu")] [When(@"user opens ""(.*)"" dropdown and selects ""(.*)"" in dropdown menu")] public async Task WhenUserSelectsInDropdownRegex(IDropdownElement dropdown, string itemText) diff --git a/Behavioral.Automation.Bindings.UI/Bindings/InputBinding.cs b/Behavioral.Automation.Bindings.UI/Bindings/InputBinding.cs index 991164de..e3c3ca3f 100644 --- a/Behavioral.Automation.Bindings.UI/Bindings/InputBinding.cs +++ b/Behavioral.Automation.Bindings.UI/Bindings/InputBinding.cs @@ -6,12 +6,10 @@ namespace Behavioral.Automation.Bindings.UI.Bindings; [Binding] public class InputBinding { - - [Given(@"""(.+?)"" text was entered into ""(.+?)"" input")] [When(@"user enters ""(.+?)"" into ""(.+?)"" input")] public async Task FillInput(string text, IInputElement input) { - await input.TypeAsync(text); + await input.InputTextAsync(text); } } \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Bindings/LabelBindings.cs b/Behavioral.Automation.Bindings.UI/Bindings/LabelBindings.cs index f9985fbc..64649913 100644 --- a/Behavioral.Automation.Bindings.UI/Bindings/LabelBindings.cs +++ b/Behavioral.Automation.Bindings.UI/Bindings/LabelBindings.cs @@ -11,7 +11,7 @@ public async Task CheckLabelText(ILabelElement label, string text) { await label.ShouldHaveTextAsync(text); } - + [Then(@"""(.+?)"" label should become visible")] public async Task CheckLabelVisibility(ILabelElement label) { diff --git a/Behavioral.Automation.Bindings.UI/Bindings/NavigationBinding.cs b/Behavioral.Automation.Bindings.UI/Bindings/NavigationBinding.cs index aac58231..9ae68c56 100644 --- a/Behavioral.Automation.Bindings.UI/Bindings/NavigationBinding.cs +++ b/Behavioral.Automation.Bindings.UI/Bindings/NavigationBinding.cs @@ -17,7 +17,7 @@ public NavigationBinding(WebContext webContext) [When(@"user opens URL ""(.+?)""")] public async Task GivenUrlIsOpened(string url) { - await _webContext.Page.GotoAsync(url); + await _webContext.Page.GoToUrlAsync(url); } [Given("application URL was opened")] diff --git a/Behavioral.Automation.Bindings.UI/Bindings/PageBinding.cs b/Behavioral.Automation.Bindings.UI/Bindings/PageBinding.cs index 5c7c9ee8..fdb49867 100644 --- a/Behavioral.Automation.Bindings.UI/Bindings/PageBinding.cs +++ b/Behavioral.Automation.Bindings.UI/Bindings/PageBinding.cs @@ -16,6 +16,6 @@ public PageBinding(WebContext webContext) [Then(@"page title should become ""(.+?)""")] public async Task ThenPageTitleShouldBe(string title) { - await _webContext.Page.ToHaveTitleAsync(title); + await _webContext.Page.HaveTitleAsync(title); } } \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Bindings/TableBinding.cs b/Behavioral.Automation.Bindings.UI/Bindings/TableBinding.cs index 3b242aa6..70e0d43d 100644 --- a/Behavioral.Automation.Bindings.UI/Bindings/TableBinding.cs +++ b/Behavioral.Automation.Bindings.UI/Bindings/TableBinding.cs @@ -6,13 +6,12 @@ namespace Behavioral.Automation.Bindings.UI.Bindings; [Binding] public class TableBinding { - [Then(@"""(.*)"" table should become visible$")] public async Task ThenTableShouldBecomeVisible(ITableWrapper table) { await table.IsVisibleAsync(); } - + [Then(@"""(.*)"" table should become visible within ""(.*)"" seconds")] public async Task ThenTableShouldBecomeVisible(ITableWrapper table, int seconds) { diff --git a/Behavioral.Automation.Bindings.UI/ElementTransformations/ElementTransformations.cs b/Behavioral.Automation.Bindings.UI/ElementTransformations/ElementTransformations.cs index ce771ce1..a0127ff2 100644 --- a/Behavioral.Automation.Bindings.UI/ElementTransformations/ElementTransformations.cs +++ b/Behavioral.Automation.Bindings.UI/ElementTransformations/ElementTransformations.cs @@ -19,21 +19,21 @@ public IInputElement GetInputElement(string caption) var element = _webElementStorageService.Get(caption + "Input"); return element; } - + [StepArgumentTransformation] public ICheckboxElement GetCheckboxElement(string caption) { var element = _webElementStorageService.Get(caption + "Checkbox"); return element; } - + [StepArgumentTransformation] public IButtonElement GetButtonElement(string caption) { var element = _webElementStorageService.Get(caption + "Button"); return element; } - + [StepArgumentTransformation] public ITableWrapper GetTableElement(string caption) { From f0b7682dbd51463c58ed7f1d684b05fc43fcdf23 Mon Sep 17 00:00:00 2001 From: Oleg Mozhey Date: Tue, 20 Feb 2024 19:33:16 +0400 Subject: [PATCH 11/20] Added where T: IWebElementWrapper to interface declaration --- .../Configurations/WebElementStorageService.cs | 2 +- .../Abstractions/IWebElementStorageService.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElementStorageService.cs b/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElementStorageService.cs index 49b718b7..9ec4ad23 100644 --- a/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElementStorageService.cs +++ b/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElementStorageService.cs @@ -4,7 +4,7 @@ namespace Behavioral.Automation.Bindings.UI.Tests.Configurations; public class WebElementStorageService : IWebElementStorageService { - public T Get(string locatorKey) + public T Get(string locatorKey) where T: IWebElement { IWebElement webElement = new WebElement(); return (T) webElement; diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IWebElementStorageService.cs b/Behavioral.Automation.Bindings.UI/Abstractions/IWebElementStorageService.cs index fa8bf4c1..a96f976d 100644 --- a/Behavioral.Automation.Bindings.UI/Abstractions/IWebElementStorageService.cs +++ b/Behavioral.Automation.Bindings.UI/Abstractions/IWebElementStorageService.cs @@ -9,5 +9,5 @@ static void RegisterWebElementImplementationAs() where TType RegisteredElements.Add(typeof(TInterface), typeof(TType)); } - T Get(string locatorKey); + T Get(string locatorKey) where T : IWebElement; } \ No newline at end of file From a357fafaa7bfc98a282b48e1e062f9d570e2e2df Mon Sep 17 00:00:00 2001 From: Oleg Mozhey Date: Tue, 20 Feb 2024 19:36:48 +0400 Subject: [PATCH 12/20] added description to ILabelInterface --- .../Abstractions/ILabelElement.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/ILabelElement.cs b/Behavioral.Automation.Bindings.UI/Abstractions/ILabelElement.cs index 593165c8..81c1b0c9 100644 --- a/Behavioral.Automation.Bindings.UI/Abstractions/ILabelElement.cs +++ b/Behavioral.Automation.Bindings.UI/Abstractions/ILabelElement.cs @@ -1,6 +1,21 @@ namespace Behavioral.Automation.Bindings.UI.Abstractions; +/// +/// Represents an interface for label web elements. +/// public interface ILabelElement : IWebElement { + /// + /// Asynchronously verifies that the element's text exactly matches the specified text. + /// + /// The expected text of the element. + /// A task representing the asynchronous check. public Task ShouldHaveTextAsync(string text); + + /// + /// Asynchronously verifies that the element's text contains the specified text. + /// + /// The text to search for within the element's text. + /// A task representing the asynchronous check. + public Task ContainsTextAsync(string text); } \ No newline at end of file From 61fa2fceb119071edeb37c583d69cdbc9d7a6b8a Mon Sep 17 00:00:00 2001 From: Oleg Mozhey Date: Wed, 21 Feb 2024 11:47:27 +0400 Subject: [PATCH 13/20] Changed variable type to var --- .../Behavioral.Automation/Services/DriverService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Behavioral.Automation.Selenium/Behavioral.Automation/Services/DriverService.cs b/Behavioral.Automation.Selenium/Behavioral.Automation/Services/DriverService.cs index c52e304d..1a166e1f 100644 --- a/Behavioral.Automation.Selenium/Behavioral.Automation/Services/DriverService.cs +++ b/Behavioral.Automation.Selenium/Behavioral.Automation/Services/DriverService.cs @@ -269,7 +269,7 @@ public string MakeScreenShot() var fileName = new string(TestContext.CurrentContext.Test.Name .Where(x => !Path.GetInvalidFileNameChars().Contains(x)) .ToArray()) + ".png"; - Screenshot screenshot = ((ITakesScreenshot)Driver).GetScreenshot(); + var screenshot = ((ITakesScreenshot)Driver).GetScreenshot(); screenshot.SaveAsFile(fileName); return fileName; } From cb2bf8d2ef17c640d06081c350f612635ea3b655 Mon Sep 17 00:00:00 2001 From: Oleg Mozhey Date: Wed, 21 Feb 2024 15:00:50 +0400 Subject: [PATCH 14/20] Deleted dropdown binding and dropdown abstraction --- .../Abstractions/IDropdownElement.cs | 6 ------ .../Bindings/DropdownBinding.cs | 15 --------------- Behavioral.Automation.Bindings.UI/CHANGELOG.md | 2 +- 3 files changed, 1 insertion(+), 22 deletions(-) delete mode 100644 Behavioral.Automation.Bindings.UI/Abstractions/IDropdownElement.cs delete mode 100644 Behavioral.Automation.Bindings.UI/Bindings/DropdownBinding.cs diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IDropdownElement.cs b/Behavioral.Automation.Bindings.UI/Abstractions/IDropdownElement.cs deleted file mode 100644 index 0f2b5626..00000000 --- a/Behavioral.Automation.Bindings.UI/Abstractions/IDropdownElement.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Behavioral.Automation.Bindings.UI.Abstractions; - -public interface IDropdownElement : IWebElement -{ - public Task OpenDropdownAndSelectAsync(string item); -} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Bindings/DropdownBinding.cs b/Behavioral.Automation.Bindings.UI/Bindings/DropdownBinding.cs deleted file mode 100644 index 70588657..00000000 --- a/Behavioral.Automation.Bindings.UI/Bindings/DropdownBinding.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Behavioral.Automation.Bindings.UI.Abstractions; -using TechTalk.SpecFlow; - -namespace Behavioral.Automation.Bindings.UI.Bindings; - -[Binding] -public class DropdownBinding -{ - [Given(@"""(.*)"" dropdown was opened and ""(.*)"" was selected in dropdown menu")] - [When(@"user opens ""(.*)"" dropdown and selects ""(.*)"" in dropdown menu")] - public async Task WhenUserSelectsInDropdownRegex(IDropdownElement dropdown, string itemText) - { - await dropdown.OpenDropdownAndSelectAsync(itemText); - } -} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/CHANGELOG.md b/Behavioral.Automation.Bindings.UI/CHANGELOG.md index 17d851e9..14b9e293 100644 --- a/Behavioral.Automation.Bindings.UI/CHANGELOG.md +++ b/Behavioral.Automation.Bindings.UI/CHANGELOG.md @@ -6,6 +6,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [0.0.1] - 17-02-2024 ### Added -- A few Button, Checkbox, Dropdown, Input, Label, Navigation, Page and Table bindings +- A few Button, Checkbox, Input, Label, Navigation, Page and Table bindings - Abstractions for WebElements and Configuration classes (for example, IWebElementStorageService) - ElementTransformations class \ No newline at end of file From 0a2fc493fd341d27b038263d49841d9606524023 Mon Sep 17 00:00:00 2001 From: Oleg Mozhey Date: Wed, 21 Feb 2024 15:07:21 +0400 Subject: [PATCH 15/20] changed back to should become visible async --- .../Configurations/WebElement.cs | 6 +++--- .../Abstractions/IWebElement.cs | 4 ++-- .../Bindings/ButtonBindings.cs | 2 +- Behavioral.Automation.Bindings.UI/Bindings/LabelBindings.cs | 2 +- Behavioral.Automation.Bindings.UI/Bindings/TableBinding.cs | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs b/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs index cc4982af..ae5005e5 100644 --- a/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs +++ b/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs @@ -12,16 +12,16 @@ public class WebElement : IWebElement public ElementSelector ElementSelector { get; } public string? Description { get; set; } - public async Task IsVisibleAsync() + public async Task ShouldBecomeVisibleAsync() { // defaultDelay = 300 is just an example of idea that we will have default delay for all elements // and ability to specify delay in test steps if we have some taking time loading // (for example, because of data processing) var defaultDelay = 300; - await IsVisibleAsync(defaultDelay); + await ShouldBecomeVisibleAsync(defaultDelay); } - public async Task IsVisibleAsync(int delay) + public async Task ShouldBecomeVisibleAsync(int delay) { throw new NotImplementedException(); } diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IWebElement.cs b/Behavioral.Automation.Bindings.UI/Abstractions/IWebElement.cs index d764a5c9..71a94498 100644 --- a/Behavioral.Automation.Bindings.UI/Abstractions/IWebElement.cs +++ b/Behavioral.Automation.Bindings.UI/Abstractions/IWebElement.cs @@ -7,6 +7,6 @@ public interface IWebElement public WebContext WebContext { get; } public ElementSelector ElementSelector { get; } public string? Description { get; set; } - public Task IsVisibleAsync(); - public Task IsVisibleAsync(int delay); + public Task ShouldBecomeVisibleAsync(); + public Task ShouldBecomeVisibleAsync(int delay); } \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Bindings/ButtonBindings.cs b/Behavioral.Automation.Bindings.UI/Bindings/ButtonBindings.cs index 98de2c39..c2b02436 100644 --- a/Behavioral.Automation.Bindings.UI/Bindings/ButtonBindings.cs +++ b/Behavioral.Automation.Bindings.UI/Bindings/ButtonBindings.cs @@ -24,7 +24,7 @@ public async Task ClickOnButton(IButtonElement button) [Then(@"""(.+?)"" button should become visible")] public async Task ButtonShouldBecomeVisible(IButtonElement button) { - await button.IsVisibleAsync(); + await button.ShouldBecomeVisibleAsync(); } [When(@"user uploads ""(.*)"" file after clicking on ""(.*)"" button")] diff --git a/Behavioral.Automation.Bindings.UI/Bindings/LabelBindings.cs b/Behavioral.Automation.Bindings.UI/Bindings/LabelBindings.cs index 64649913..cc4b425b 100644 --- a/Behavioral.Automation.Bindings.UI/Bindings/LabelBindings.cs +++ b/Behavioral.Automation.Bindings.UI/Bindings/LabelBindings.cs @@ -15,6 +15,6 @@ public async Task CheckLabelText(ILabelElement label, string text) [Then(@"""(.+?)"" label should become visible")] public async Task CheckLabelVisibility(ILabelElement label) { - await label.IsVisibleAsync(); + await label.ShouldBecomeVisibleAsync(); } } \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Bindings/TableBinding.cs b/Behavioral.Automation.Bindings.UI/Bindings/TableBinding.cs index 70e0d43d..70f83761 100644 --- a/Behavioral.Automation.Bindings.UI/Bindings/TableBinding.cs +++ b/Behavioral.Automation.Bindings.UI/Bindings/TableBinding.cs @@ -9,12 +9,12 @@ public class TableBinding [Then(@"""(.*)"" table should become visible$")] public async Task ThenTableShouldBecomeVisible(ITableWrapper table) { - await table.IsVisibleAsync(); + await table.ShouldBecomeVisibleAsync(); } [Then(@"""(.*)"" table should become visible within ""(.*)"" seconds")] public async Task ThenTableShouldBecomeVisible(ITableWrapper table, int seconds) { - await table.IsVisibleAsync(seconds); + await table.ShouldBecomeVisibleAsync(seconds); } } \ No newline at end of file From 2c2a307ee89b3bb192a0063f46637672067c146b Mon Sep 17 00:00:00 2001 From: Oleg Mozhey Date: Wed, 21 Feb 2024 17:14:01 +0400 Subject: [PATCH 16/20] updated project --- .../Abstractions/ICheckboxElement.cs | 6 --- .../Abstractions/IFileChooser.cs | 6 --- .../Abstractions/IInputElement.cs | 6 --- .../Abstractions/ILabelElement.cs | 21 --------- .../Abstractions/ITableWrapper.cs | 5 --- .../Abstractions/IWebElement.cs | 12 ------ .../Behavioral.Automation.Bindings.UI.csproj | 33 -------------- .../Bindings/ButtonBindings.cs | 39 ----------------- .../Bindings/CheckboxBindings.cs | 15 ------- .../Bindings/InputBinding.cs | 15 ------- .../Bindings/LabelBindings.cs | 20 --------- .../Bindings/NavigationBinding.cs | 28 ------------ .../Bindings/PageBinding.cs | 21 --------- .../Bindings/TableBinding.cs | 20 --------- .../CHANGELOG.md | 11 ----- .../ElementTransformations.cs | 43 ------------------- .../Abstractions/ElementSelector.cs | 2 +- .../Abstractions/IBrowser.cs | 2 +- .../Abstractions/IButtonElement.cs | 2 +- .../Abstractions/IPage.cs | 3 +- .../Abstractions/IWebElement.cs | 12 ++++++ .../Abstractions/IWebElementStorageService.cs | 2 +- ...Behavioral.Automation.Interfaces.UI.csproj | 17 ++++++++ .../CHANGELOG.md | 0 .../Context/WebContext.cs | 4 +- .../ElementTransformations.cs | 22 ++++++++++ Behavioral.Automation.Interfaces.UI/README.md | 1 + Behavioral.Automation.sln | 11 +---- 28 files changed, 61 insertions(+), 318 deletions(-) delete mode 100644 Behavioral.Automation.Bindings.UI/Abstractions/ICheckboxElement.cs delete mode 100644 Behavioral.Automation.Bindings.UI/Abstractions/IFileChooser.cs delete mode 100644 Behavioral.Automation.Bindings.UI/Abstractions/IInputElement.cs delete mode 100644 Behavioral.Automation.Bindings.UI/Abstractions/ILabelElement.cs delete mode 100644 Behavioral.Automation.Bindings.UI/Abstractions/ITableWrapper.cs delete mode 100644 Behavioral.Automation.Bindings.UI/Abstractions/IWebElement.cs delete mode 100644 Behavioral.Automation.Bindings.UI/Behavioral.Automation.Bindings.UI.csproj delete mode 100644 Behavioral.Automation.Bindings.UI/Bindings/ButtonBindings.cs delete mode 100644 Behavioral.Automation.Bindings.UI/Bindings/CheckboxBindings.cs delete mode 100644 Behavioral.Automation.Bindings.UI/Bindings/InputBinding.cs delete mode 100644 Behavioral.Automation.Bindings.UI/Bindings/LabelBindings.cs delete mode 100644 Behavioral.Automation.Bindings.UI/Bindings/NavigationBinding.cs delete mode 100644 Behavioral.Automation.Bindings.UI/Bindings/PageBinding.cs delete mode 100644 Behavioral.Automation.Bindings.UI/Bindings/TableBinding.cs delete mode 100644 Behavioral.Automation.Bindings.UI/CHANGELOG.md delete mode 100644 Behavioral.Automation.Bindings.UI/ElementTransformations/ElementTransformations.cs rename {Behavioral.Automation.Bindings.UI => Behavioral.Automation.Interfaces.UI}/Abstractions/ElementSelector.cs (66%) rename {Behavioral.Automation.Bindings.UI => Behavioral.Automation.Interfaces.UI}/Abstractions/IBrowser.cs (62%) rename {Behavioral.Automation.Bindings.UI => Behavioral.Automation.Interfaces.UI}/Abstractions/IButtonElement.cs (55%) rename {Behavioral.Automation.Bindings.UI => Behavioral.Automation.Interfaces.UI}/Abstractions/IPage.cs (59%) create mode 100644 Behavioral.Automation.Interfaces.UI/Abstractions/IWebElement.cs rename {Behavioral.Automation.Bindings.UI => Behavioral.Automation.Interfaces.UI}/Abstractions/IWebElementStorageService.cs (85%) create mode 100644 Behavioral.Automation.Interfaces.UI/Behavioral.Automation.Interfaces.UI.csproj rename Behavioral.Automation.Bindings.UI/README.md => Behavioral.Automation.Interfaces.UI/CHANGELOG.md (100%) rename {Behavioral.Automation.Bindings.UI => Behavioral.Automation.Interfaces.UI}/Context/WebContext.cs (66%) create mode 100644 Behavioral.Automation.Interfaces.UI/ElementTransformations/ElementTransformations.cs create mode 100644 Behavioral.Automation.Interfaces.UI/README.md diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/ICheckboxElement.cs b/Behavioral.Automation.Bindings.UI/Abstractions/ICheckboxElement.cs deleted file mode 100644 index 76288212..00000000 --- a/Behavioral.Automation.Bindings.UI/Abstractions/ICheckboxElement.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Behavioral.Automation.Bindings.UI.Abstractions; - -public interface ICheckboxElement : IWebElement -{ - public Task ClickAsync(); -} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IFileChooser.cs b/Behavioral.Automation.Bindings.UI/Abstractions/IFileChooser.cs deleted file mode 100644 index 26b8a918..00000000 --- a/Behavioral.Automation.Bindings.UI/Abstractions/IFileChooser.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Behavioral.Automation.Bindings.UI.Abstractions; - -public interface IFileChooser -{ - public Task UploadFileAsync(string filePath); -} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IInputElement.cs b/Behavioral.Automation.Bindings.UI/Abstractions/IInputElement.cs deleted file mode 100644 index 9f868cc7..00000000 --- a/Behavioral.Automation.Bindings.UI/Abstractions/IInputElement.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Behavioral.Automation.Bindings.UI.Abstractions; - -public interface IInputElement : IWebElement -{ - public Task InputTextAsync(string text); -} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/ILabelElement.cs b/Behavioral.Automation.Bindings.UI/Abstractions/ILabelElement.cs deleted file mode 100644 index 81c1b0c9..00000000 --- a/Behavioral.Automation.Bindings.UI/Abstractions/ILabelElement.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Behavioral.Automation.Bindings.UI.Abstractions; - -/// -/// Represents an interface for label web elements. -/// -public interface ILabelElement : IWebElement -{ - /// - /// Asynchronously verifies that the element's text exactly matches the specified text. - /// - /// The expected text of the element. - /// A task representing the asynchronous check. - public Task ShouldHaveTextAsync(string text); - - /// - /// Asynchronously verifies that the element's text contains the specified text. - /// - /// The text to search for within the element's text. - /// A task representing the asynchronous check. - public Task ContainsTextAsync(string text); -} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/ITableWrapper.cs b/Behavioral.Automation.Bindings.UI/Abstractions/ITableWrapper.cs deleted file mode 100644 index 8b9f51bf..00000000 --- a/Behavioral.Automation.Bindings.UI/Abstractions/ITableWrapper.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace Behavioral.Automation.Bindings.UI.Abstractions; - -public interface ITableWrapper : IWebElement -{ -} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IWebElement.cs b/Behavioral.Automation.Bindings.UI/Abstractions/IWebElement.cs deleted file mode 100644 index 71a94498..00000000 --- a/Behavioral.Automation.Bindings.UI/Abstractions/IWebElement.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Behavioral.Automation.Bindings.UI.Context; - -namespace Behavioral.Automation.Bindings.UI.Abstractions; - -public interface IWebElement -{ - public WebContext WebContext { get; } - public ElementSelector ElementSelector { get; } - public string? Description { get; set; } - public Task ShouldBecomeVisibleAsync(); - public Task ShouldBecomeVisibleAsync(int delay); -} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Behavioral.Automation.Bindings.UI.csproj b/Behavioral.Automation.Bindings.UI/Behavioral.Automation.Bindings.UI.csproj deleted file mode 100644 index 339d5d4c..00000000 --- a/Behavioral.Automation.Bindings.UI/Behavioral.Automation.Bindings.UI.csproj +++ /dev/null @@ -1,33 +0,0 @@ - - - - net6.0 - enable - enable - AnyCPU - Behavioral.Automation.Bindings.UI - 0.0.1 - Quantori Inc. - tas - Quantori Inc. - Apache-2.0 - true - Quantori BDD is a automation framework that makes use of a wide array of existing grammatical structures, including abstractions, implementations, and bindings, while also offering strong customization options for any implementations. - - The whole Framework is divided into the following parts: - - Bindings (Abstractions including configuration interfaces) - - Implementation of abstractions - - Project configurations - - Feature files - - https://github.com/quantori/Behavioral.Automation - true - - - - - - - - - diff --git a/Behavioral.Automation.Bindings.UI/Bindings/ButtonBindings.cs b/Behavioral.Automation.Bindings.UI/Bindings/ButtonBindings.cs deleted file mode 100644 index c2b02436..00000000 --- a/Behavioral.Automation.Bindings.UI/Bindings/ButtonBindings.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Behavioral.Automation.Bindings.UI.Abstractions; -using Behavioral.Automation.Bindings.UI.Context; -using TechTalk.SpecFlow; - -namespace Behavioral.Automation.Bindings.UI.Bindings; - -[Binding] -public class ButtonBindings -{ - private readonly WebContext _webContext; - - public ButtonBindings(WebContext webContext) - { - _webContext = webContext; - } - - [Given(@"""(.+?)"" button has been clicked")] - [When(@"user clicks on ""(.+?)"" button")] - public async Task ClickOnButton(IButtonElement button) - { - await button.ClickAsync(); - } - - [Then(@"""(.+?)"" button should become visible")] - public async Task ButtonShouldBecomeVisible(IButtonElement button) - { - await button.ShouldBecomeVisibleAsync(); - } - - [When(@"user uploads ""(.*)"" file after clicking on ""(.*)"" button")] - public async Task WhenUserUploadsFileAfterClickingOnButton(string filePath, IButtonElement button) - { - var fileChooser = await _webContext.Page.RunAndWaitForFileChooserAsync(async () => - { - await button.ClickAsync(); - }); - await fileChooser.UploadFileAsync(filePath); - } -} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Bindings/CheckboxBindings.cs b/Behavioral.Automation.Bindings.UI/Bindings/CheckboxBindings.cs deleted file mode 100644 index 7854f5c5..00000000 --- a/Behavioral.Automation.Bindings.UI/Bindings/CheckboxBindings.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Behavioral.Automation.Bindings.UI.Abstractions; -using TechTalk.SpecFlow; - -namespace Behavioral.Automation.Bindings.UI.Bindings; - -[Binding] -public class CheckboxBindings -{ - [Given(@"""(.+?)"" checkbox was clicked")] - [When(@"user clicks on ""(.+?)"" checkbox")] - public async Task ClickOnCheckbox(ICheckboxElement checkbox) - { - await checkbox.ClickAsync(); - } -} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Bindings/InputBinding.cs b/Behavioral.Automation.Bindings.UI/Bindings/InputBinding.cs deleted file mode 100644 index e3c3ca3f..00000000 --- a/Behavioral.Automation.Bindings.UI/Bindings/InputBinding.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Behavioral.Automation.Bindings.UI.Abstractions; -using TechTalk.SpecFlow; - -namespace Behavioral.Automation.Bindings.UI.Bindings; - -[Binding] -public class InputBinding -{ - [Given(@"""(.+?)"" text was entered into ""(.+?)"" input")] - [When(@"user enters ""(.+?)"" into ""(.+?)"" input")] - public async Task FillInput(string text, IInputElement input) - { - await input.InputTextAsync(text); - } -} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Bindings/LabelBindings.cs b/Behavioral.Automation.Bindings.UI/Bindings/LabelBindings.cs deleted file mode 100644 index cc4b425b..00000000 --- a/Behavioral.Automation.Bindings.UI/Bindings/LabelBindings.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Behavioral.Automation.Bindings.UI.Abstractions; -using TechTalk.SpecFlow; - -namespace Behavioral.Automation.Bindings.UI.Bindings; - -[Binding] -public class LabelBindings -{ - [Then(@"""(.+?)"" label should have ""(.+?)"" text")] - public async Task CheckLabelText(ILabelElement label, string text) - { - await label.ShouldHaveTextAsync(text); - } - - [Then(@"""(.+?)"" label should become visible")] - public async Task CheckLabelVisibility(ILabelElement label) - { - await label.ShouldBecomeVisibleAsync(); - } -} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Bindings/NavigationBinding.cs b/Behavioral.Automation.Bindings.UI/Bindings/NavigationBinding.cs deleted file mode 100644 index 9ae68c56..00000000 --- a/Behavioral.Automation.Bindings.UI/Bindings/NavigationBinding.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Behavioral.Automation.Bindings.UI.Context; -using TechTalk.SpecFlow; - -namespace Behavioral.Automation.Bindings.UI.Bindings; - -[Binding] -public class NavigationBinding -{ - private readonly WebContext _webContext; - - public NavigationBinding(WebContext webContext) - { - _webContext = webContext; - } - - [Given(@"URL ""(.+?)"" was opened")] - [When(@"user opens URL ""(.+?)""")] - public async Task GivenUrlIsOpened(string url) - { - await _webContext.Page.GoToUrlAsync(url); - } - - [Given("application URL was opened")] - public async Task GivenApplicationUrlIsOpened() - { - await _webContext.Page.GoToApplicationUrlAsync(); - } -} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Bindings/PageBinding.cs b/Behavioral.Automation.Bindings.UI/Bindings/PageBinding.cs deleted file mode 100644 index fdb49867..00000000 --- a/Behavioral.Automation.Bindings.UI/Bindings/PageBinding.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Behavioral.Automation.Bindings.UI.Context; -using TechTalk.SpecFlow; - -namespace Behavioral.Automation.Bindings.UI.Bindings; - -[Binding] -public class PageBinding -{ - private readonly WebContext _webContext; - - public PageBinding(WebContext webContext) - { - _webContext = webContext; - } - - [Then(@"page title should become ""(.+?)""")] - public async Task ThenPageTitleShouldBe(string title) - { - await _webContext.Page.HaveTitleAsync(title); - } -} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Bindings/TableBinding.cs b/Behavioral.Automation.Bindings.UI/Bindings/TableBinding.cs deleted file mode 100644 index 70f83761..00000000 --- a/Behavioral.Automation.Bindings.UI/Bindings/TableBinding.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Behavioral.Automation.Bindings.UI.Abstractions; -using TechTalk.SpecFlow; - -namespace Behavioral.Automation.Bindings.UI.Bindings; - -[Binding] -public class TableBinding -{ - [Then(@"""(.*)"" table should become visible$")] - public async Task ThenTableShouldBecomeVisible(ITableWrapper table) - { - await table.ShouldBecomeVisibleAsync(); - } - - [Then(@"""(.*)"" table should become visible within ""(.*)"" seconds")] - public async Task ThenTableShouldBecomeVisible(ITableWrapper table, int seconds) - { - await table.ShouldBecomeVisibleAsync(seconds); - } -} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/CHANGELOG.md b/Behavioral.Automation.Bindings.UI/CHANGELOG.md deleted file mode 100644 index 14b9e293..00000000 --- a/Behavioral.Automation.Bindings.UI/CHANGELOG.md +++ /dev/null @@ -1,11 +0,0 @@ -# Changelog -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -[0.0.1] - 17-02-2024 -### Added -- A few Button, Checkbox, Input, Label, Navigation, Page and Table bindings -- Abstractions for WebElements and Configuration classes (for example, IWebElementStorageService) -- ElementTransformations class \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/ElementTransformations/ElementTransformations.cs b/Behavioral.Automation.Bindings.UI/ElementTransformations/ElementTransformations.cs deleted file mode 100644 index a0127ff2..00000000 --- a/Behavioral.Automation.Bindings.UI/ElementTransformations/ElementTransformations.cs +++ /dev/null @@ -1,43 +0,0 @@ -using Behavioral.Automation.Bindings.UI.Abstractions; -using TechTalk.SpecFlow; - -namespace Behavioral.Automation.Bindings.UI.ElementTransformations; - -[Binding] -public class ElementTransformations -{ - private readonly IWebElementStorageService _webElementStorageService; - - public ElementTransformations(IWebElementStorageService webElementStorageService) - { - _webElementStorageService = webElementStorageService; - } - - [StepArgumentTransformation] - public IInputElement GetInputElement(string caption) - { - var element = _webElementStorageService.Get(caption + "Input"); - return element; - } - - [StepArgumentTransformation] - public ICheckboxElement GetCheckboxElement(string caption) - { - var element = _webElementStorageService.Get(caption + "Checkbox"); - return element; - } - - [StepArgumentTransformation] - public IButtonElement GetButtonElement(string caption) - { - var element = _webElementStorageService.Get(caption + "Button"); - return element; - } - - [StepArgumentTransformation] - public ITableWrapper GetTableElement(string caption) - { - var element = _webElementStorageService.Get(caption + "Table"); - return element; - } -} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/ElementSelector.cs b/Behavioral.Automation.Interfaces.UI/Abstractions/ElementSelector.cs similarity index 66% rename from Behavioral.Automation.Bindings.UI/Abstractions/ElementSelector.cs rename to Behavioral.Automation.Interfaces.UI/Abstractions/ElementSelector.cs index 4ecd862e..56c991de 100644 --- a/Behavioral.Automation.Bindings.UI/Abstractions/ElementSelector.cs +++ b/Behavioral.Automation.Interfaces.UI/Abstractions/ElementSelector.cs @@ -1,4 +1,4 @@ -namespace Behavioral.Automation.Bindings.UI.Abstractions; +namespace Behavioral.Automation.Interfaces.UI.Abstractions; public class ElementSelector { diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IBrowser.cs b/Behavioral.Automation.Interfaces.UI/Abstractions/IBrowser.cs similarity index 62% rename from Behavioral.Automation.Bindings.UI/Abstractions/IBrowser.cs rename to Behavioral.Automation.Interfaces.UI/Abstractions/IBrowser.cs index c12bd5f4..3f96061b 100644 --- a/Behavioral.Automation.Bindings.UI/Abstractions/IBrowser.cs +++ b/Behavioral.Automation.Interfaces.UI/Abstractions/IBrowser.cs @@ -1,4 +1,4 @@ -namespace Behavioral.Automation.Bindings.UI.Abstractions; +namespace Behavioral.Automation.Interfaces.UI.Abstractions; public interface IBrowser { diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IButtonElement.cs b/Behavioral.Automation.Interfaces.UI/Abstractions/IButtonElement.cs similarity index 55% rename from Behavioral.Automation.Bindings.UI/Abstractions/IButtonElement.cs rename to Behavioral.Automation.Interfaces.UI/Abstractions/IButtonElement.cs index 6242b054..d8d6096c 100644 --- a/Behavioral.Automation.Bindings.UI/Abstractions/IButtonElement.cs +++ b/Behavioral.Automation.Interfaces.UI/Abstractions/IButtonElement.cs @@ -1,4 +1,4 @@ -namespace Behavioral.Automation.Bindings.UI.Abstractions; +namespace Behavioral.Automation.Interfaces.UI.Abstractions; public interface IButtonElement : IWebElement { diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IPage.cs b/Behavioral.Automation.Interfaces.UI/Abstractions/IPage.cs similarity index 59% rename from Behavioral.Automation.Bindings.UI/Abstractions/IPage.cs rename to Behavioral.Automation.Interfaces.UI/Abstractions/IPage.cs index 1d00ebcc..01852843 100644 --- a/Behavioral.Automation.Bindings.UI/Abstractions/IPage.cs +++ b/Behavioral.Automation.Interfaces.UI/Abstractions/IPage.cs @@ -1,10 +1,9 @@ -namespace Behavioral.Automation.Bindings.UI.Abstractions; +namespace Behavioral.Automation.Interfaces.UI.Abstractions; public interface IPage { public Task GoToUrlAsync(string url); public Task GoToApplicationUrlAsync(); public Task HaveTitleAsync(string title); - public Task RunAndWaitForFileChooserAsync(Func action); public Task ScreenshotAsync(string path); } \ No newline at end of file diff --git a/Behavioral.Automation.Interfaces.UI/Abstractions/IWebElement.cs b/Behavioral.Automation.Interfaces.UI/Abstractions/IWebElement.cs new file mode 100644 index 00000000..bfdfe3a8 --- /dev/null +++ b/Behavioral.Automation.Interfaces.UI/Abstractions/IWebElement.cs @@ -0,0 +1,12 @@ +using Behavioral.Automation.Interfaces.UI.Context; + +namespace Behavioral.Automation.Interfaces.UI.Abstractions; + +public interface IWebElement +{ + public WebContext WebContext { get; } + public ElementSelector ElementSelector { get; } + public string? Description { get; set; } + public bool IsVisible(); + public bool IsVisible(int delay); +} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI/Abstractions/IWebElementStorageService.cs b/Behavioral.Automation.Interfaces.UI/Abstractions/IWebElementStorageService.cs similarity index 85% rename from Behavioral.Automation.Bindings.UI/Abstractions/IWebElementStorageService.cs rename to Behavioral.Automation.Interfaces.UI/Abstractions/IWebElementStorageService.cs index a96f976d..487baea6 100644 --- a/Behavioral.Automation.Bindings.UI/Abstractions/IWebElementStorageService.cs +++ b/Behavioral.Automation.Interfaces.UI/Abstractions/IWebElementStorageService.cs @@ -1,4 +1,4 @@ -namespace Behavioral.Automation.Bindings.UI.Abstractions; +namespace Behavioral.Automation.Interfaces.UI.Abstractions; public interface IWebElementStorageService { diff --git a/Behavioral.Automation.Interfaces.UI/Behavioral.Automation.Interfaces.UI.csproj b/Behavioral.Automation.Interfaces.UI/Behavioral.Automation.Interfaces.UI.csproj new file mode 100644 index 00000000..bc7ab96d --- /dev/null +++ b/Behavioral.Automation.Interfaces.UI/Behavioral.Automation.Interfaces.UI.csproj @@ -0,0 +1,17 @@ + + + + net6.0 + enable + enable + AnyCPU + Behavioral.Automation.Interfaces.UI + + + + + + + + + diff --git a/Behavioral.Automation.Bindings.UI/README.md b/Behavioral.Automation.Interfaces.UI/CHANGELOG.md similarity index 100% rename from Behavioral.Automation.Bindings.UI/README.md rename to Behavioral.Automation.Interfaces.UI/CHANGELOG.md diff --git a/Behavioral.Automation.Bindings.UI/Context/WebContext.cs b/Behavioral.Automation.Interfaces.UI/Context/WebContext.cs similarity index 66% rename from Behavioral.Automation.Bindings.UI/Context/WebContext.cs rename to Behavioral.Automation.Interfaces.UI/Context/WebContext.cs index a8913a8f..3c9acb86 100644 --- a/Behavioral.Automation.Bindings.UI/Context/WebContext.cs +++ b/Behavioral.Automation.Interfaces.UI/Context/WebContext.cs @@ -1,6 +1,6 @@ -using Behavioral.Automation.Bindings.UI.Abstractions; +using Behavioral.Automation.Interfaces.UI.Abstractions; -namespace Behavioral.Automation.Bindings.UI.Context; +namespace Behavioral.Automation.Interfaces.UI.Context; /* WebContext holds UI-related instances that can be reused across steps: diff --git a/Behavioral.Automation.Interfaces.UI/ElementTransformations/ElementTransformations.cs b/Behavioral.Automation.Interfaces.UI/ElementTransformations/ElementTransformations.cs new file mode 100644 index 00000000..5fd03e8a --- /dev/null +++ b/Behavioral.Automation.Interfaces.UI/ElementTransformations/ElementTransformations.cs @@ -0,0 +1,22 @@ +using Behavioral.Automation.Interfaces.UI.Abstractions; +using TechTalk.SpecFlow; + +namespace Behavioral.Automation.Interfaces.UI.ElementTransformations; + +[Binding] +public class ElementTransformations +{ + private readonly IWebElementStorageService _webElementStorageService; + + public ElementTransformations(IWebElementStorageService webElementStorageService) + { + _webElementStorageService = webElementStorageService; + } + + [StepArgumentTransformation] + public IButtonElement GetButtonElement(string caption) + { + var element = _webElementStorageService.Get(caption + "Button"); + return element; + } +} \ No newline at end of file diff --git a/Behavioral.Automation.Interfaces.UI/README.md b/Behavioral.Automation.Interfaces.UI/README.md new file mode 100644 index 00000000..2fd9f957 --- /dev/null +++ b/Behavioral.Automation.Interfaces.UI/README.md @@ -0,0 +1 @@ +TBD \ No newline at end of file diff --git a/Behavioral.Automation.sln b/Behavioral.Automation.sln index f0a4b49e..d4344e4a 100644 --- a/Behavioral.Automation.sln +++ b/Behavioral.Automation.sln @@ -26,11 +26,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UITests", "Behavioral.Autom EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{FA8E07DE-0779-44A0-AFF2-2C2573DD6611}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Behavioral.Automation.Bindings.UI", "Behavioral.Automation.Bindings.UI\Behavioral.Automation.Bindings.UI.csproj", "{DB675416-81CA-40EA-A1D9-F45E75248F74}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Behavioral.Automation.Interfaces.UI", "Behavioral.Automation.Interfaces.UI\Behavioral.Automation.Interfaces.UI.csproj", "{DB675416-81CA-40EA-A1D9-F45E75248F74}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Behavioral.Automation.Buildings.UI", "Behavioral.Automation.Buildings.UI", "{C6D1A214-4D90-4973-83A0-4D1D1EA5DE30}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Behavioral.Automation.Bindings.UI.Tests", "Behavioral.Automation.Bindings.UI.Tests\Behavioral.Automation.Bindings.UI.Tests.csproj", "{D536A13B-0F79-4F01-9A8D-CAAD4A3811CD}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Behavioral.Automation.Interfaces.UI", "Behavioral.Automation.Interfaces.UI", "{C6D1A214-4D90-4973-83A0-4D1D1EA5DE30}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -74,10 +72,6 @@ Global {DB675416-81CA-40EA-A1D9-F45E75248F74}.Debug|Any CPU.Build.0 = Debug|Any CPU {DB675416-81CA-40EA-A1D9-F45E75248F74}.Release|Any CPU.ActiveCfg = Release|Any CPU {DB675416-81CA-40EA-A1D9-F45E75248F74}.Release|Any CPU.Build.0 = Release|Any CPU - {D536A13B-0F79-4F01-9A8D-CAAD4A3811CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D536A13B-0F79-4F01-9A8D-CAAD4A3811CD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D536A13B-0F79-4F01-9A8D-CAAD4A3811CD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D536A13B-0F79-4F01-9A8D-CAAD4A3811CD}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -92,7 +86,6 @@ Global {FA8E07DE-0779-44A0-AFF2-2C2573DD6611} = {2A26C467-6A03-4942-9F9B-62F77F992F70} {1498E9EA-13DE-4C6A-AB63-960D226F6FCE} = {FA8E07DE-0779-44A0-AFF2-2C2573DD6611} {DB675416-81CA-40EA-A1D9-F45E75248F74} = {C6D1A214-4D90-4973-83A0-4D1D1EA5DE30} - {D536A13B-0F79-4F01-9A8D-CAAD4A3811CD} = {C6D1A214-4D90-4973-83A0-4D1D1EA5DE30} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {724FD185-E1F2-44BD-89EA-DFD1DBF6453A} From b958619281a2b26677b61c2266881228d4e6af6b Mon Sep 17 00:00:00 2001 From: Oleg Mozhey Date: Wed, 21 Feb 2024 17:19:40 +0400 Subject: [PATCH 17/20] delete unit test --- ...vioral.Automation.Bindings.UI.Tests.csproj | 33 ------------------- .../Configurations/Hooks.cs | 22 ------------- .../Configurations/WebElement.cs | 28 ---------------- .../WebElementStorageService.cs | 12 ------- .../UIBindingsCanBeUsedTests.feature | 6 ---- .../specflow.json | 16 --------- 6 files changed, 117 deletions(-) delete mode 100644 Behavioral.Automation.Bindings.UI.Tests/Behavioral.Automation.Bindings.UI.Tests.csproj delete mode 100644 Behavioral.Automation.Bindings.UI.Tests/Configurations/Hooks.cs delete mode 100644 Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs delete mode 100644 Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElementStorageService.cs delete mode 100644 Behavioral.Automation.Bindings.UI.Tests/UIBindingsCanBeUsedTests.feature delete mode 100644 Behavioral.Automation.Bindings.UI.Tests/specflow.json diff --git a/Behavioral.Automation.Bindings.UI.Tests/Behavioral.Automation.Bindings.UI.Tests.csproj b/Behavioral.Automation.Bindings.UI.Tests/Behavioral.Automation.Bindings.UI.Tests.csproj deleted file mode 100644 index 64495414..00000000 --- a/Behavioral.Automation.Bindings.UI.Tests/Behavioral.Automation.Bindings.UI.Tests.csproj +++ /dev/null @@ -1,33 +0,0 @@ - - - - net6.0 - enable - enable - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - - Always - - - - diff --git a/Behavioral.Automation.Bindings.UI.Tests/Configurations/Hooks.cs b/Behavioral.Automation.Bindings.UI.Tests/Configurations/Hooks.cs deleted file mode 100644 index 5e7c64be..00000000 --- a/Behavioral.Automation.Bindings.UI.Tests/Configurations/Hooks.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Behavioral.Automation.Bindings.UI.Abstractions; -using BoDi; -using TechTalk.SpecFlow; - -namespace Behavioral.Automation.Bindings.UI.Tests.Configurations; - -[Binding] -public class Configuration -{ - private readonly IObjectContainer _objectContainer; - - public Configuration(IObjectContainer objectContainer) - { - _objectContainer = objectContainer; - } - - [BeforeScenario] - public void ResolveDependencyInjectionInterfaces() - { - _objectContainer.RegisterTypeAs(); - } -} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs b/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs deleted file mode 100644 index ae5005e5..00000000 --- a/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElement.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Behavioral.Automation.Bindings.UI.Abstractions; -using Behavioral.Automation.Bindings.UI.Context; - -namespace Behavioral.Automation.Bindings.UI.Tests.Configurations; - -/* - * Shared code between all web Elements - */ -public class WebElement : IWebElement -{ - public WebContext WebContext { get; } - public ElementSelector ElementSelector { get; } - public string? Description { get; set; } - - public async Task ShouldBecomeVisibleAsync() - { - // defaultDelay = 300 is just an example of idea that we will have default delay for all elements - // and ability to specify delay in test steps if we have some taking time loading - // (for example, because of data processing) - var defaultDelay = 300; - await ShouldBecomeVisibleAsync(defaultDelay); - } - - public async Task ShouldBecomeVisibleAsync(int delay) - { - throw new NotImplementedException(); - } -} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElementStorageService.cs b/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElementStorageService.cs deleted file mode 100644 index 9ec4ad23..00000000 --- a/Behavioral.Automation.Bindings.UI.Tests/Configurations/WebElementStorageService.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Behavioral.Automation.Bindings.UI.Abstractions; - -namespace Behavioral.Automation.Bindings.UI.Tests.Configurations; - -public class WebElementStorageService : IWebElementStorageService -{ - public T Get(string locatorKey) where T: IWebElement - { - IWebElement webElement = new WebElement(); - return (T) webElement; - } -} \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI.Tests/UIBindingsCanBeUsedTests.feature b/Behavioral.Automation.Bindings.UI.Tests/UIBindingsCanBeUsedTests.feature deleted file mode 100644 index d8e61809..00000000 --- a/Behavioral.Automation.Bindings.UI.Tests/UIBindingsCanBeUsedTests.feature +++ /dev/null @@ -1,6 +0,0 @@ -Feature: Test cases to check that UI bindings can be used by specflow framework -The test cases check only configuration of BDD framework - dependencies and abstraction classes -The implementation of Interfaces should be tested in other projects - - Scenario: Simple button click test - Given "Test" button has been clicked \ No newline at end of file diff --git a/Behavioral.Automation.Bindings.UI.Tests/specflow.json b/Behavioral.Automation.Bindings.UI.Tests/specflow.json deleted file mode 100644 index 492c3f17..00000000 --- a/Behavioral.Automation.Bindings.UI.Tests/specflow.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "bindingCulture": { - "language": "en-us" - }, - "language": { - "feature": "en-us" - }, - "runtime": { - "missingOrPendingStepsOutcome": "Error" - }, - "stepAssemblies": [ - { - "assembly": "Behavioral.Automation.Bindings.UI" - } - ] -} From 79344a9f8f6b4a61509459a3032169cfe92d86e9 Mon Sep 17 00:00:00 2001 From: Oleg Mozhey Date: Wed, 21 Feb 2024 17:22:58 +0400 Subject: [PATCH 18/20] deleted isVisible --- Behavioral.Automation.Interfaces.UI/Abstractions/IWebElement.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Behavioral.Automation.Interfaces.UI/Abstractions/IWebElement.cs b/Behavioral.Automation.Interfaces.UI/Abstractions/IWebElement.cs index bfdfe3a8..1297959d 100644 --- a/Behavioral.Automation.Interfaces.UI/Abstractions/IWebElement.cs +++ b/Behavioral.Automation.Interfaces.UI/Abstractions/IWebElement.cs @@ -7,6 +7,4 @@ public interface IWebElement public WebContext WebContext { get; } public ElementSelector ElementSelector { get; } public string? Description { get; set; } - public bool IsVisible(); - public bool IsVisible(int delay); } \ No newline at end of file From 14cec4c2db42369a62872b62e965ed6a4b83d78b Mon Sep 17 00:00:00 2001 From: Oleg Mozhey Date: Wed, 21 Feb 2024 17:52:31 +0400 Subject: [PATCH 19/20] deleted classes --- .../Abstractions/ElementSelector.cs | 8 -------- .../Abstractions/IWebElement.cs | 4 ---- .../Context/WebContext.cs | 15 --------------- 3 files changed, 27 deletions(-) delete mode 100644 Behavioral.Automation.Interfaces.UI/Abstractions/ElementSelector.cs delete mode 100644 Behavioral.Automation.Interfaces.UI/Context/WebContext.cs diff --git a/Behavioral.Automation.Interfaces.UI/Abstractions/ElementSelector.cs b/Behavioral.Automation.Interfaces.UI/Abstractions/ElementSelector.cs deleted file mode 100644 index 56c991de..00000000 --- a/Behavioral.Automation.Interfaces.UI/Abstractions/ElementSelector.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Behavioral.Automation.Interfaces.UI.Abstractions; - -public class ElementSelector -{ - public string? IdSelector { get; set; } - - public string? XpathSelector { get; set; } -} \ No newline at end of file diff --git a/Behavioral.Automation.Interfaces.UI/Abstractions/IWebElement.cs b/Behavioral.Automation.Interfaces.UI/Abstractions/IWebElement.cs index 1297959d..9ab47ced 100644 --- a/Behavioral.Automation.Interfaces.UI/Abstractions/IWebElement.cs +++ b/Behavioral.Automation.Interfaces.UI/Abstractions/IWebElement.cs @@ -1,10 +1,6 @@ -using Behavioral.Automation.Interfaces.UI.Context; - namespace Behavioral.Automation.Interfaces.UI.Abstractions; public interface IWebElement { - public WebContext WebContext { get; } - public ElementSelector ElementSelector { get; } public string? Description { get; set; } } \ No newline at end of file diff --git a/Behavioral.Automation.Interfaces.UI/Context/WebContext.cs b/Behavioral.Automation.Interfaces.UI/Context/WebContext.cs deleted file mode 100644 index 3c9acb86..00000000 --- a/Behavioral.Automation.Interfaces.UI/Context/WebContext.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Behavioral.Automation.Interfaces.UI.Abstractions; - -namespace Behavioral.Automation.Interfaces.UI.Context; - -/* -WebContext holds UI-related instances that can be reused across steps: -1. Browser -2. Tab (coming soon) -3. Page - */ -public class WebContext -{ - public IBrowser Browser { get; set; } - public IPage Page { get; set; } -} \ No newline at end of file From 351a49a373e612e9c1d665be4cf4ebcc9042d4ea Mon Sep 17 00:00:00 2001 From: Oleg Mozhey Date: Wed, 21 Feb 2024 17:55:07 +0400 Subject: [PATCH 20/20] delete more --- .../ElementTransformations.cs | 22 ------------------- 1 file changed, 22 deletions(-) delete mode 100644 Behavioral.Automation.Interfaces.UI/ElementTransformations/ElementTransformations.cs diff --git a/Behavioral.Automation.Interfaces.UI/ElementTransformations/ElementTransformations.cs b/Behavioral.Automation.Interfaces.UI/ElementTransformations/ElementTransformations.cs deleted file mode 100644 index 5fd03e8a..00000000 --- a/Behavioral.Automation.Interfaces.UI/ElementTransformations/ElementTransformations.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Behavioral.Automation.Interfaces.UI.Abstractions; -using TechTalk.SpecFlow; - -namespace Behavioral.Automation.Interfaces.UI.ElementTransformations; - -[Binding] -public class ElementTransformations -{ - private readonly IWebElementStorageService _webElementStorageService; - - public ElementTransformations(IWebElementStorageService webElementStorageService) - { - _webElementStorageService = webElementStorageService; - } - - [StepArgumentTransformation] - public IButtonElement GetButtonElement(string caption) - { - var element = _webElementStorageService.Get(caption + "Button"); - return element; - } -} \ No newline at end of file